[PATCH v2 5/5] iommu/arm-smmu: Convert to domain_alloc_paging()

Jason Gunthorpe jgg at nvidia.com
Tue Dec 12 06:03:07 PST 2023


On Tue, Dec 12, 2023 at 01:26:51PM +0000, Will Deacon wrote:
> > @@ -862,6 +859,18 @@ static struct iommu_domain *arm_smmu_domain_alloc(unsigned type)
> >  	mutex_init(&smmu_domain->init_mutex);
> >  	spin_lock_init(&smmu_domain->cb_lock);
> >  
> > +	if (dev)
> > +		cfg = dev_iommu_priv_get(dev);
> > +	if (cfg) {
> > +		int ret;
> > +
> > +		ret = arm_smmu_init_domain_context(smmu_domain, cfg->smmu, dev);
> > +		if (ret) {
> > +			kfree(smmu_domain);
> > +			return NULL;
> 
> If we're just returning NULL, can we drop 'ret'?

It is waiting to be changed to ERR_PTR. The dependent patches are
merged to rc5 now, so I can fix it in v3.

> > +		}
> > +	}
> > +
> >  	return &smmu_domain->domain;
> 
> Why do we need to handle the 'dev && !cfg' case here, instead g
> returning NULL?

dev && !cfg is impossible these days, so we can shuffle the if and
then just crash on that case like the other drivers do.

Jason



More information about the linux-arm-kernel mailing list