[Mesa-dev] [PATCH v14 15/36] i965: Improve same-buffer restriction for imports

Varad Gautam varad.gautam at collabora.com
Mon Jun 5 14:13:56 UTC 2017


Hi Daniel,

On Mon, 2017-06-05 at 14:53 +0100, Daniel Stone wrote:
> Hi Varad,
> 
> On 30 May 2017 at 12:53, Varad Gautam <varadgautam at gmail.com> wrote:
> > 
> > +   /* We only support all planes from the same bo.
> > +    * brw_bo_gem_create_from_prime() should return the same pointer for all
> > +    * fds received here */
> > +   bo = brw_bo_gem_create_from_prime(screen->bufmgr, fds[0], size);
> > +   for (i = 1; i < num_fds; i++) {
> > +      if (bo != brw_bo_gem_create_from_prime(screen->bufmgr, fds[i], size))
> > +         return NULL;
> 
> This above takes a ref, which gets leaked.
> 
>            struct brw_bo *aux =
> brw_bo_gem_create_from_prime(screen->bufmgr, fds[i], size);
>            brw_bo_unreference(aux);
>            if (aux != bo)

Thanks for spotting this. Can the unref(aux) happen before comparing against bo?
Or should this be something like:
   for (...) {
      struct brw_bo *aux = brw_bo_gem_create_from_prime(screen->bufmgr, fds[i],
size);
      if (aux != bo) {
         brw_bo_unreference(aux);
         return NULL;
      }
      brw_bo_unreference(aux);
   }
>               return NULL;
> 
> Thanks for the fix!
> 
> Cheers,
> Daniel


More information about the mesa-dev mailing list