Skip to content

Commit bb6bccb

Browse files
pyma1joergroedel
authored andcommitted
iommu/amd: Fix NULL dereference bug in match_hid_uid
Add a non-NULL check to fix potential NULL pointer dereference Cleanup code to call function once. Signed-off-by: Aaron Ma <aaron.ma@canonical.com> Fixes: 2bf9a0a ('iommu/amd: Add iommu support for ACPI HID devices') Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent d05e4c8 commit bb6bccb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/iommu/amd_iommu.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,14 @@ static struct lock_class_key reserved_rbtree_key;
140140
static inline int match_hid_uid(struct device *dev,
141141
struct acpihid_map_entry *entry)
142142
{
143+
struct acpi_device *adev = ACPI_COMPANION(dev);
143144
const char *hid, *uid;
144145

145-
hid = acpi_device_hid(ACPI_COMPANION(dev));
146-
uid = acpi_device_uid(ACPI_COMPANION(dev));
146+
if (!adev)
147+
return -ENODEV;
148+
149+
hid = acpi_device_hid(adev);
150+
uid = acpi_device_uid(adev);
147151

148152
if (!hid || !(*hid))
149153
return -ENODEV;

0 commit comments

Comments
 (0)