Linux IOMMU Development
 help / color / mirror / Atom feed
From: Matthias Brugger <matthias.bgg@gmail.com>
To: Yang Yingliang <yangyingliang@huawei.com>,
	iommu@lists.linux.dev, linux-mediatek@lists.infradead.org
Cc: yong.wu@mediatek.com, joro@8bytes.org, will@kernel.org,
	robin.murphy@arm.com
Subject: Re: [PATCH] iommu/mediatek: check return value after calling platform_get_resource()
Date: Mon, 7 Nov 2022 17:03:20 +0100	[thread overview]
Message-ID: <d9498f83-14db-79b6-eacb-f7530af02466@gmail.com> (raw)
In-Reply-To: <20221029103550.3774365-1-yangyingliang@huawei.com>



On 29/10/2022 12:35, Yang Yingliang wrote:
> platform_get_resource() may return NULL pointer, we need check its
> return value to avoid null-ptr-deref in resource_size().
> 
> Fixes: 42d57fc58aeb ("iommu/mediatek: Initialise/Remove for multi bank dev")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>   drivers/iommu/mtk_iommu.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> index 2ab2ecfe01f8..2d14dc846b83 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -1173,6 +1173,8 @@ static int mtk_iommu_probe(struct platform_device *pdev)
>   
>   	banks_num = data->plat_data->banks_num;
>   	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!res)
> +		return -EINVAL;

That would be the case if the DT passed to the kernel isn't correct, but anyway:

Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>

>   	if (resource_size(res) < banks_num * MTK_IOMMU_BANK_SZ) {
>   		dev_err(dev, "banknr %d. res %pR is not enough.\n", banks_num, res);
>   		return -EINVAL;

  reply	other threads:[~2022-11-07 16:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-29 10:35 [PATCH] iommu/mediatek: check return value after calling platform_get_resource() Yang Yingliang
2022-11-07 16:03 ` Matthias Brugger [this message]
2022-11-19  9:09 ` Joerg Roedel
  -- strict thread matches above, loose matches on Subject: below --
2022-07-04  7:59 Yang Yingliang via iommu
2022-07-04  7:59 ` Yang Yingliang

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=d9498f83-14db-79b6-eacb-f7530af02466@gmail.com \
    --to=matthias.bgg@gmail.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    --cc=yangyingliang@huawei.com \
    --cc=yong.wu@mediatek.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