linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/mediatek: Fix forever loop in error handling
@ 2022-12-07 15:56 Dan Carpenter
  2022-12-08  1:06 ` Yong Wu (吴勇)
  2022-12-12 11:06 ` Joerg Roedel
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2022-12-07 15:56 UTC (permalink / raw)
  To: Yong Wu
  Cc: Joerg Roedel, Will Deacon, Robin Murphy, Matthias Brugger,
	AngeloGioacchino Del Regno, iommu, linux-mediatek,
	kernel-janitors

There is a typo so this loop does i++ where i-- was intended.  It will
result in looping until the kernel crashes.

Fixes: 26593928564c ("iommu/mediatek: Add error path for loop of mm_dts_parse")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
 drivers/iommu/mtk_iommu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
index 3e46bc8b0714..2badd6acfb23 100644
--- a/drivers/iommu/mtk_iommu.c
+++ b/drivers/iommu/mtk_iommu.c
@@ -1160,8 +1160,7 @@ static int mtk_iommu_mm_dts_parse(struct device *dev, struct component_match **m
 	return 0;
 
 err_larbdev_put:
-	/* id may be not linear mapping, loop whole the array */
-	for (i = MTK_LARB_NR_MAX - 1; i >= 0; i++) {
+	for (i = MTK_LARB_NR_MAX - 1; i >= 0; i--) {
 		if (!data->larb_imu[i].dev)
 			continue;
 		put_device(data->larb_imu[i].dev);
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommu/mediatek: Fix forever loop in error handling
  2022-12-07 15:56 [PATCH] iommu/mediatek: Fix forever loop in error handling Dan Carpenter
@ 2022-12-08  1:06 ` Yong Wu (吴勇)
  2022-12-09  2:20   ` Yong Wu (吴勇)
  2022-12-12 11:06 ` Joerg Roedel
  1 sibling, 1 reply; 4+ messages in thread
From: Yong Wu (吴勇) @ 2022-12-08  1:06 UTC (permalink / raw)
  To: error27@gmail.com
  Cc: kernel-janitors@vger.kernel.org,
	linux-mediatek@lists.infradead.org, robin.murphy@arm.com,
	joro@8bytes.org, iommu@lists.linux.dev, matthias.bgg@gmail.com,
	angelogioacchino.delregno@collabora.com, will@kernel.org

On Wed, 2022-12-07 at 18:56 +0300, Dan Carpenter wrote:
> There is a typo so this loop does i++ where i-- was intended.  It
> will
> result in looping until the kernel crashes.
> 
> Fixes: 26593928564c ("iommu/mediatek: Add error path for loop of
> mm_dts_parse")
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Sorry for this.

Reviewed-by: Yong Wu <yong.wu@mediatek.com>

Thanks Dan.

> ---
>  drivers/iommu/mtk_iommu.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> index 3e46bc8b0714..2badd6acfb23 100644
> --- a/drivers/iommu/mtk_iommu.c
> +++ b/drivers/iommu/mtk_iommu.c
> @@ -1160,8 +1160,7 @@ static int mtk_iommu_mm_dts_parse(struct device
> *dev, struct component_match **m
>  	return 0;
>  
>  err_larbdev_put:
> -	/* id may be not linear mapping, loop whole the array */
> -	for (i = MTK_LARB_NR_MAX - 1; i >= 0; i++) {
> +	for (i = MTK_LARB_NR_MAX - 1; i >= 0; i--) {
>  		if (!data->larb_imu[i].dev)
>  			continue;
>  		put_device(data->larb_imu[i].dev);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommu/mediatek: Fix forever loop in error handling
  2022-12-08  1:06 ` Yong Wu (吴勇)
@ 2022-12-09  2:20   ` Yong Wu (吴勇)
  0 siblings, 0 replies; 4+ messages in thread
From: Yong Wu (吴勇) @ 2022-12-09  2:20 UTC (permalink / raw)
  To: joro@8bytes.org, error27@gmail.com, broonie@kernel.org
  Cc: kernel-janitors@vger.kernel.org,
	linux-mediatek@lists.infradead.org, robin.murphy@arm.com,
	kernelci-results@groups.io, iommu@lists.linux.dev,
	matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com,
	will@kernel.org

Hi Joerg,

On Thu, 2022-12-08 at 09:06 +0800, YongWu wrote:
> On Wed, 2022-12-07 at 18:56 +0300, Dan Carpenter wrote:
> > There is a typo so this loop does i++ where i-- was intended.  It
> > will
> > result in looping until the kernel crashes.
> > 
> > Fixes: 26593928564c ("iommu/mediatek: Add error path for loop of
> > mm_dts_parse")
> > Signed-off-by: Dan Carpenter <error27@gmail.com>
> 
> Sorry for this.
> 
> Reviewed-by: Yong Wu <yong.wu@mediatek.com>
> 
> Thanks Dan.

Could you help apply this?

I reproduced this below issue, and it could be fixed by this patch.

https://lore.kernel.org/linux-mediatek/Y5HrIhEfuEgGKuMB@sirena.org.uk/

Thanks.

> 
> > ---
> >  drivers/iommu/mtk_iommu.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> > index 3e46bc8b0714..2badd6acfb23 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -1160,8 +1160,7 @@ static int mtk_iommu_mm_dts_parse(struct
> > device
> > *dev, struct component_match **m
> >  	return 0;
> >  
> >  err_larbdev_put:
> > -	/* id may be not linear mapping, loop whole the array */
> > -	for (i = MTK_LARB_NR_MAX - 1; i >= 0; i++) {
> > +	for (i = MTK_LARB_NR_MAX - 1; i >= 0; i--) {
> >  		if (!data->larb_imu[i].dev)
> >  			continue;
> >  		put_device(data->larb_imu[i].dev);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommu/mediatek: Fix forever loop in error handling
  2022-12-07 15:56 [PATCH] iommu/mediatek: Fix forever loop in error handling Dan Carpenter
  2022-12-08  1:06 ` Yong Wu (吴勇)
@ 2022-12-12 11:06 ` Joerg Roedel
  1 sibling, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2022-12-12 11:06 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Yong Wu, Will Deacon, Robin Murphy, Matthias Brugger,
	AngeloGioacchino Del Regno, iommu, linux-mediatek,
	kernel-janitors

On Wed, Dec 07, 2022 at 06:56:09PM +0300, Dan Carpenter wrote:
> There is a typo so this loop does i++ where i-- was intended.  It will
> result in looping until the kernel crashes.
> 
> Fixes: 26593928564c ("iommu/mediatek: Add error path for loop of mm_dts_parse")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
>  drivers/iommu/mtk_iommu.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Applied, thanks.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-12 11:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-07 15:56 [PATCH] iommu/mediatek: Fix forever loop in error handling Dan Carpenter
2022-12-08  1:06 ` Yong Wu (吴勇)
2022-12-09  2:20   ` Yong Wu (吴勇)
2022-12-12 11:06 ` Joerg Roedel

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