From: tangzhenhao <tzh18@mails.tsinghua.edu.cn>
To: iommu@lists.linux-foundation.org
Cc: tangzhenhao <tzh18@mails.tsinghua.edu.cn>
Subject: [PATCH] drivers/iommu: fix a null-ptr-deref bug in msm_iommu.c
Date: Sun, 6 Dec 2020 01:43:51 -0800 [thread overview]
Message-ID: <20201206094351.47860-1-tzh18@mails.tsinghua.edu.cn> (raw)
At line 600 in drivers/iommu/msm_iommu.c, the ret-val of kzalloc should be checked to avoid null-ptr-deref bug.
Signed-off-by: tangzhenhao <tzh18@mails.tsinghua.edu.cn>
---
drivers/iommu/msm_iommu.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/iommu/msm_iommu.c b/drivers/iommu/msm_iommu.c
index 3615cd6241c4..e3c576e5babb 100644
--- a/drivers/iommu/msm_iommu.c
+++ b/drivers/iommu/msm_iommu.c
@@ -598,6 +598,10 @@ static void insert_iommu_master(struct device *dev,
if (list_empty(&(*iommu)->ctx_list)) {
master = kzalloc(sizeof(*master), GFP_ATOMIC);
+ if (!master) {
+ dev_err(dev, "Failed to allocate IOMMU context bank instance\n");
+ return;
+ }
master->of_node = dev->of_node;
list_add(&master->list, &(*iommu)->ctx_list);
dev_iommu_priv_set(dev, master);
--
2.17.1
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next reply other threads:[~2020-12-06 14:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-06 9:43 tangzhenhao [this message]
2020-12-10 9:13 ` [PATCH] drivers/iommu: fix a null-ptr-deref bug in msm_iommu.c Will Deacon
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=20201206094351.47860-1-tzh18@mails.tsinghua.edu.cn \
--to=tzh18@mails.tsinghua.edu.cn \
--cc=iommu@lists.linux-foundation.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).