Linux IOMMU Development
 help / color / mirror / Atom feed
From: "Yong Wu (吴勇)" <Yong.Wu@mediatek.com>
To: "joro@8bytes.org" <joro@8bytes.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>
Cc: "robin.murphy@arm.com" <robin.murphy@arm.com>,
	"will@kernel.org" <will@kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>
Subject: Re: [PATCH] iommu/mediatek: Remove a unnecessary checking for larbid
Date: Wed, 5 Jul 2023 06:49:11 +0000	[thread overview]
Message-ID: <ca4a06b89442e56df652c4aeba3ad83473f4db58.camel@mediatek.com> (raw)
In-Reply-To: <633be7a7-0bb8-1575-535e-2f96302198bd@collabora.com>

On Tue, 2023-07-04 at 14:19 +0200, AngeloGioacchino Del Regno wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  Il 04/07/23 13:56, Yong Wu ha scritto:
> > Fix a coverity issue:
> > 
> >>> assignment: Assigning: larbid = (fwspec->ids[0] >> 5) & 0x1fU.
> > larbid = MTK_M4U_TO_LARB(fwspec->ids[0]);
> >>> between: At condition larbid >= 32U, the value of larbid must be
> between
> >>> 0 and 31.
> >>> dead_error_condition: The condition larbid >= 32U cannot be true.
> > if (larbid >= MTK_LARB_NR_MAX)
> >>> CID 11306470 (#1 of 1): Logically dead code (DEADCODE)
> >>> dead_error_line: Execution cannot reach this statement:
> >>> return ERR_PTR(-22L);
> >          return ERR_PTR(-EINVAL);
> > 
> > The checking "if (larbid >= MTK_LARB_NR_MAX)" is unnecessary.
> > 
> 
> I agree with the coverity tool in that after the transformation
> (going through
> the definition of MTK_M4U_TO_LARB) the check is pointless, but I
> think that the
> right fix here is to check for validity of fwspec->ids[0] instead of
> simply
> removing validation.
> 
> Having no validation after mtk_iommu_probe_device() is fine, but
> that's
> because we assume that *this* function performs all validation steps.

There already is validation code at the point later in this function.

"if (!larbdev) return ERR_PTR(-EINVAL);" //if the larbid is invalid.

This patch just removes a deadcode.

> 
> Regards,
> Angelo
> 
> > Signed-off-by: Yong Wu <yong.wu@mediatek.com>
> > ---
> > Rebase on v6.4-rc1.
> > ---
> >   drivers/iommu/mtk_iommu.c | 3 ---
> >   1 file changed, 3 deletions(-)
> > 
> > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> > index aecc7d154f28..67caa90b481b 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -838,9 +838,6 @@ static struct iommu_device
> *mtk_iommu_probe_device(struct device *dev)
> >    * All the ports in each a device should be in the same larbs.
> >    */
> >   larbid = MTK_M4U_TO_LARB(fwspec->ids[0]);
> > -if (larbid >= MTK_LARB_NR_MAX)
> > -return ERR_PTR(-EINVAL);
> > -
> >   for (i = 1; i < fwspec->num_ids; i++) {
> >   larbidx = MTK_M4U_TO_LARB(fwspec->ids[i]);
> >   if (larbid != larbidx) {
> 
> 

  reply	other threads:[~2023-07-05  7:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-04 11:56 [PATCH] iommu/mediatek: Remove a unnecessary checking for larbid Yong Wu
2023-07-04 12:19 ` AngeloGioacchino Del Regno
2023-07-05  6:49   ` Yong Wu (吴勇) [this message]
2023-07-05  8:26     ` Robin Murphy
2023-07-05  8:31       ` AngeloGioacchino Del Regno

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=ca4a06b89442e56df652c4aeba3ad83473f4db58.camel@mediatek.com \
    --to=yong.wu@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=robin.murphy@arm.com \
    --cc=will@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