thunderbolt: Fix possible NULL pointer dereference in tb_acpi_add_link()
authorMario Limonciello <mario.limonciello@dell.com>
Mon, 26 Oct 2020 16:12:59 +0000 (19:12 +0300)
committerMika Westerberg <mika.westerberg@linux.intel.com>
Thu, 28 Jan 2021 12:30:57 +0000 (15:30 +0300)
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>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
drivers/thunderbolt/acpi.c

index a5f988a..b5442f9 100644 (file)
@@ -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)