From: Aaron Ma <aaron.ma@canonical.com>
To: joro@8bytes.org, iommu@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, aaron.ma@canonical.com
Subject: [RESEND][PATCH] iommu/amd: Fix NULL dereference bug in match_hid_uid
Date: Wed, 13 Mar 2019 21:53:24 +0800 [thread overview]
Message-ID: <1552485204-11381-1-git-send-email-aaron.ma@canonical.com> (raw)
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>
---
drivers/iommu/amd_iommu.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c
index 2a7b78bb98b4..dbda5b86f979 100644
--- a/drivers/iommu/amd_iommu.c
+++ b/drivers/iommu/amd_iommu.c
@@ -140,9 +140,14 @@ static inline int match_hid_uid(struct device *dev,
struct acpihid_map_entry *entry)
{
const char *hid, *uid;
+ struct acpi_device *adev = ACPI_COMPANION(dev);
- 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;
--
2.20.1
next reply other threads:[~2019-03-13 13:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-13 13:53 Aaron Ma [this message]
2019-03-15 15:24 ` [RESEND][PATCH] iommu/amd: Fix NULL dereference bug in match_hid_uid Joerg Roedel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1552485204-11381-1-git-send-email-aaron.ma@canonical.com \
--to=aaron.ma@canonical.com \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).