Message ID | Y5C3mTam2nkbaz6o@kili (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | iommu/mediatek: Fix forever loop in error handling | expand |
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);
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);
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.
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);
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(-)