On Thu, Oct 29, 2026 at 02:26:01PM +0000, [email protected] wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
> to consider:
> - [Medium] accel: ethosu: mixing __free() and scoped_guard() with goto 
> cleanup labels
> --
> 
> commit cbd771f7e8b7995eaa7aedcd81a7cde35a4b6ada
> Author: Rob Herring (Arm) <[email protected]>
> 
> accel: ethosu: Guard operations after unplug
> 
> This commit guards ethosu device file open and private ioctl operations
> with drm_dev_enter() and drm_dev_exit(), and switches device removal from
> drm_dev_unregister() to drm_dev_unplug(). It also drops drm_dev_enter()
> from the BO wait ioctl so fence waits do not delay scheduler teardown.
> 
> > diff --git a/drivers/accel/ethosu/ethosu_drv.c 
> > b/drivers/accel/ethosu/ethosu_drv.c
> > index 6875ed17a004d..91b2c2ab0a03e 100644
> > --- a/drivers/accel/ethosu/ethosu_drv.c
> > +++ b/drivers/accel/ethosu/ethosu_drv.c
> [ ... ]
> > @@ -139,27 +132,34 @@ static int ethosu_ioctl_cmdstream_bo_create(struct 
> > drm_device *ddev, void *data,
> >  
> >  static int ethosu_open(struct drm_device *ddev, struct drm_file *file)
> >  {
> > -   int ret = 0;
> > +   struct ethosu_file_priv __free(kfree) * priv = NULL;
> > +   int cookie, ret;
> >  
> >     if (!try_module_get(THIS_MODULE))
> >             return -EINVAL;
> > +   if (!drm_dev_enter(ddev, &cookie)) {
> > +           module_put(THIS_MODULE);
> > +           return -ENODEV;
> > +   }
> >  
> > -   struct ethosu_file_priv __free(kfree) *priv = kzalloc_obj(*priv);
> > +   priv = kzalloc_obj(*priv);
> >     if (!priv) {
> >             ret = -ENOMEM;
> > -           goto err_put_mod;
> > +           goto err_dev_exit;
> >     }
> >     priv->edev = to_ethosu_device(ddev);
> >  
> >     ret = ethosu_job_open(priv);
> >     if (ret)
> > -           goto err_put_mod;
> > +           goto err_dev_exit;
> >  
> >     ethosu_perfmon_open_file(priv);
> >     file->driver_priv = no_free_ptr(priv);
> > +   drm_dev_exit(cookie);
> >     return 0;
> >  
> > -err_put_mod:
> > +err_dev_exit:
> > +   drm_dev_exit(cookie);
> >     module_put(THIS_MODULE);
> >     return ret;
> >  }
> 
> [Severity: Medium]
> In drivers/accel/ethosu/ethosu_drv.c, ethosu_open() declares priv with
> __free(kfree) = NULL at the top of the function before try_module_get() and
> drm_dev_enter(), and then mixes __free(kfree) with goto err_dev_exit when
> kzalloc_obj() or ethosu_job_open() fails.
> 
> Because scope-based cleanup runs when the function scope exits after the
> err_dev_exit label executes, drm_dev_exit(cookie) and
> module_put(THIS_MODULE) will run before kfree(priv), reversing the reverse
> acquisition (lifo) teardown order and mixing goto error handling with
> cleanup.h helpers.
> 
> Should ethosu_open() avoid mixing __free(kfree) and goto labels so that
> priv is freed before exiting the drm device section and dropping the module
> reference?

No! There's no such requirement that everything uses scoped cleanups or 
nothing does. And delaying a free is not an issue.

Rob

Reply via email to