summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAaron Ma <aaron.ma@canonical.com>2019-03-13 21:53:24 +0800
committerJoerg Roedel <jroedel@suse.de>2019-03-15 16:22:05 +0100
commitbb6bccba390c7d743c1e4427de4ef284c8cc6869 (patch)
tree6ecc7bc4382425f2d9a4b0188848b9454261cbf9 /drivers
parentd05e4c8600c36084ce9de6249bb972c9bdd75b7e (diff)
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: 2bf9a0a12749b ('iommu/amd: Add iommu support for ACPI HID devices') Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iommu/amd_iommu.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 6b0760dafb3e..b319e51c379b 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -140,10 +140,14 @@ static struct lock_class_key reserved_rbtree_key;
static inline int match_hid_uid(struct device *dev,
struct acpihid_map_entry *entry)
{
+ struct acpi_device *adev = ACPI_COMPANION(dev);
const char *hid, *uid;
- hid = acpi_device_hid(ACPI_COMPANION(dev));
- uid = acpi_device_uid(ACPI_COMPANION(dev));
+ if (!adev)
+ return -ENODEV;
+
+ hid = acpi_device_hid(adev);
+ uid = acpi_device_uid(adev);
if (!hid || !(*hid))
return -ENODEV;