lkml.org 
[lkml]   [2020]   [Oct]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] iommu/rockchip: check return value of of_find_device_by_node() in rk_iommu_of_xlate()
From
Date
On 2020-10-29 09:22, Yu Kuai wrote:
> 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.

How can that happen? (Given that ".suppress_bind_attrs = true")

Robin.

> 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);
>
>

\
 
 \ /
  Last update: 2020-10-29 11:08    [W:0.074 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site