[PATCH v5 15/27] iommu/mediatek: Add fail handle for sysfs_add and device_register

Yong Wu yong.wu at mediatek.com
Tue Dec 29 06:00:20 EST 2020


On Wed, 2020-12-23 at 17:25 +0900, Tomasz Figa wrote:
> On Wed, Dec 09, 2020 at 04:00:50PM +0800, Yong Wu wrote:
> > Add fail handle for iommu_device_sysfs_add and iommu_device_register.
> > 
> > Fixes: b16c0170b53c ("iommu/mediatek: Make use of iommu_device_register interface")
> > Signed-off-by: Yong Wu <yong.wu at mediatek.com>
> > ---
> >  drivers/iommu/mtk_iommu.c | 13 +++++++++++--
> >  1 file changed, 11 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c
> > index 39478cfbe0f1..09c8c58feb78 100644
> > --- a/drivers/iommu/mtk_iommu.c
> > +++ b/drivers/iommu/mtk_iommu.c
> > @@ -746,7 +746,7 @@ static int mtk_iommu_probe(struct platform_device *pdev)
> >  
> >  	ret = iommu_device_register(&data->iommu);
> >  	if (ret)
> > -		return ret;
> > +		goto out_sysfs_remove;
> >  
> >  	spin_lock_init(&data->tlb_lock);
> >  	list_add_tail(&data->list, &m4ulist);
> > @@ -754,7 +754,16 @@ static int mtk_iommu_probe(struct platform_device *pdev)
> >  	if (!iommu_present(&platform_bus_type))
> >  		bus_set_iommu(&platform_bus_type, &mtk_iommu_ops);
> >  
> > -	return component_master_add_with_match(dev, &mtk_iommu_com_ops, match);
> > +	ret = component_master_add_with_match(dev, &mtk_iommu_com_ops, match);
> > +	if (ret)
> > +		goto out_dev_unreg;
> > +	return ret;
> > +
> > +out_dev_unreg:
> 
> Shouldn't other operations be undone as well? I can see that above
> bus_set_iommu() is set and an entry is added to m4ulist.

Oh. Yes. I will add them. and remove the fixes tag since they are not
introduced by it. these error handle are not added in the first version.

> 
> > +	iommu_device_unregister(&data->iommu);
> > +out_sysfs_remove:
> > +	iommu_device_sysfs_remove(&data->iommu);
> > +	return ret;
> >  }
> >  
> >  static int mtk_iommu_remove(struct platform_device *pdev)
> > -- 
> > 2.18.0
> > 
> > _______________________________________________
> > iommu mailing list
> > iommu at lists.linux-foundation.org
> > https://lists.linuxfoundation.org/mailman/listinfo/iommu



More information about the linux-arm-kernel mailing list