From: Yu Kuai <yukuai3@huawei.com>
To: <joro@8bytes.org>, <heiko@sntech.de>, <robin.murphy@arm.com>,
<jeffy.chen@rock-chips.com>
Cc: yi.zhang@huawei.com, linux-kernel@vger.kernel.org,
linux-rockchip@lists.infradead.org,
iommu@lists.linux-foundation.org, yukuai3@huawei.com,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH] iommu/rockchip: check return value of of_find_device_by_node() in rk_iommu_of_xlate()
Date: Thu, 29 Oct 2020 17:22:02 +0800 [thread overview]
Message-ID: <20201029092202.900218-1-yukuai3@huawei.com> (raw)
If of_find_device_by_node() failed in rk_iommu_of_xlate(), null pointer
dereference will be triggered. Thus return error code if
of_find_device_by_node() failed.
Fixes: 5fd577c3eac3("iommu/rockchip: Use OF_IOMMU to attach devices automatically")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/iommu/rockchip-iommu.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c
index e5d86b7177de..090d149ef8e9 100644
--- a/drivers/iommu/rockchip-iommu.c
+++ b/drivers/iommu/rockchip-iommu.c
@@ -1099,6 +1099,9 @@ static int rk_iommu_of_xlate(struct device *dev,
iommu_dev = of_find_device_by_node(args->np);
+ if (!iommu_dev)
+ return -ENODEV;
+
data->iommu = platform_get_drvdata(iommu_dev);
dev_iommu_priv_set(dev, data);
--
2.25.4
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next reply other threads:[~2020-10-29 9:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 9:22 Yu Kuai [this message]
2020-10-29 10:08 ` [PATCH] iommu/rockchip: check return value of of_find_device_by_node() in rk_iommu_of_xlate() Robin Murphy
2020-10-29 13:19 ` yukuai (C)
2020-10-29 13:51 ` Robin Murphy
2020-10-30 1:27 ` yukuai (C)
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=20201029092202.900218-1-yukuai3@huawei.com \
--to=yukuai3@huawei.com \
--cc=heiko@sntech.de \
--cc=iommu@lists.linux-foundation.org \
--cc=jeffy.chen@rock-chips.com \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=robin.murphy@arm.com \
--cc=yi.zhang@huawei.com \
/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).