On Tue, Nov 04, 2025 at 11:58:24PM -0800, Alex Mastro wrote:
> On Mon, Oct 27, 2025 at 02:31:02PM -0300, Jason Gunthorpe wrote:
> > @@ -1024,8 +1027,15 @@ static int iopt_fill_domain(struct io_pagetable 
> > *iopt,
> >                     continue;
> >  
> >             mutex_lock(&pages->mutex);
> > +           if (iopt_is_dmabuf(pages)) {
> > +                   rc = iopt_dmabuf_track_domain(pages, area, domain);
> > +                   if (rc)
> > +                           goto out_unfill;
> 
> I think this error path results in locking pages->mutex recursively. Needs a
> mutex_unlock(&pages->mutex)?

Yes, let's use a guard then:

--- a/drivers/iommu/iommufd/io_pagetable.c
+++ b/drivers/iommu/iommufd/io_pagetable.c
@@ -1056,7 +1056,7 @@ static int iopt_fill_domain(struct io_pagetable *iopt,
                if (!pages)
                        continue;
 
-               mutex_lock(&pages->mutex);
+               guard(mutex)(&pages->mutex);
                if (iopt_is_dmabuf(pages)) {
                        rc = iopt_dmabuf_track_domain(pages, area, domain);
                        if (rc)
@@ -1066,7 +1066,6 @@ static int iopt_fill_domain(struct io_pagetable *iopt,
                if (rc) {
                        if (iopt_is_dmabuf(pages))
                                iopt_dmabuf_untrack_domain(pages, area, domain);
-                       mutex_unlock(&pages->mutex);
                        goto out_unfill;
                }
                if (!area->storage_domain) {

Thanks,
Jason

Reply via email to