diff mbox series

[1/6] thunderbolt: Fix possible NULL pointer dereference in tb_acpi_add_link()

Message ID 20210126155723.9388-2-mika.westerberg@linux.intel.com
State Accepted
Commit 4d395c5e74398f664405819330e5a298da37f655
Headers show
Series [1/6] thunderbolt: Fix possible NULL pointer dereference in tb_acpi_add_link() | expand

Commit Message

Mika Westerberg Jan. 26, 2021, 3:57 p.m. UTC
From: Mario Limonciello <mario.limonciello@dell.com>

When we walk up the device hierarchy in tb_acpi_add_link() make sure we
break the loop if the device has no parent. Otherwise we may crash the
kernel by dereferencing a NULL pointer.

Fixes: b2be2b05cf3b ("thunderbolt: Create device links from ACPI description")
Cc: stable@vger.kernel.org
Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/acpi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mika Westerberg Jan. 28, 2021, 12:36 p.m. UTC | #1
On Tue, Jan 26, 2021 at 06:57:18PM +0300, Mika Westerberg wrote:
> From: Mario Limonciello <mario.limonciello@dell.com>

> 

> When we walk up the device hierarchy in tb_acpi_add_link() make sure we

> break the loop if the device has no parent. Otherwise we may crash the

> kernel by dereferencing a NULL pointer.

> 

> Fixes: b2be2b05cf3b ("thunderbolt: Create device links from ACPI description")

> Cc: stable@vger.kernel.org

> Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>

> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>


Applied this one separately to thunderbolt.git/fixes.
diff mbox series

Patch

diff --git a/drivers/thunderbolt/acpi.c b/drivers/thunderbolt/acpi.c
index a5f988a9f948..b5442f979b4d 100644
--- a/drivers/thunderbolt/acpi.c
+++ b/drivers/thunderbolt/acpi.c
@@ -56,7 +56,7 @@  static acpi_status tb_acpi_add_link(acpi_handle handle, u32 level, void *data,
 	 * managed with the xHCI and the SuperSpeed hub so we create the
 	 * link from xHCI instead.
 	 */
-	while (!dev_is_pci(dev))
+	while (dev && !dev_is_pci(dev))
 		dev = dev->parent;
 
 	if (!dev)