Re: [PATCH rdma-next 1/6] RDMA/uverbs: Introduce UCAP (User CAPabilities) API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 05, 2025 at 02:01:13PM +0530, Kalesh Anakkur Purayil wrote:
> On Wed, Feb 26, 2025 at 7:50 PM Leon Romanovsky <leon@xxxxxxxxxx> wrote:
> >
> > From: Chiara Meiohas <cmeiohas@xxxxxxxxxx>
> >
> > Implement a new User CAPabilities (UCAP) API to provide fine-grained
> > control over specific firmware features.
> >
> > This approach offers more granular capabilities than the existing Linux
> > capabilities, which may be too generic for certain FW features.
> >
> > This mechanism represents each capability as a character device with
> > root read-write access. Root processes can grant users special
> > privileges by allowing access to these character devices (e.g., using
> > chown).
> >
> > UCAP character devices are located in /dev/infiniband and the class path
> > is /sys/class/infiniband_ucaps.
> >
> > Signed-off-by: Chiara Meiohas <cmeiohas@xxxxxxxxxx>
> > Reviewed-by: Yishai Hadas <yishaih@xxxxxxxxxx>
> > Signed-off-by: Leon Romanovsky <leon@xxxxxxxxxx>
> > ---
> >  drivers/infiniband/core/Makefile      |   3 +-
> >  drivers/infiniband/core/ucaps.c       | 255 ++++++++++++++++++++++++++
> >  drivers/infiniband/core/uverbs_main.c |   2 +
> >  include/rdma/ib_ucaps.h               |  25 +++
> >  4 files changed, 284 insertions(+), 1 deletion(-)
> >  create mode 100644 drivers/infiniband/core/ucaps.c
> >  create mode 100644 include/rdma/ib_ucaps.h

<...>

> > +       device_initialize(&ucap->dev);
> > +       ucap->dev.class = &ucaps_class;
> > +       ucap->dev.devt = MKDEV(MAJOR(ucaps_base_dev), type);
> > +       ucap->dev.release = ucap_dev_release;
> > +       dev_set_name(&ucap->dev, ucap_names[type]);
> > +
> > +       cdev_init(&ucap->cdev, &ucaps_cdev_fops);
> > +       ucap->cdev.owner = THIS_MODULE;
> > +
> > +       ret = cdev_device_add(&ucap->cdev, &ucap->dev);
> > +       if (ret)
> > +               goto err_device;
> Memory leak in the error path, need to free ucap here?

It is done through call to put_device(&ucap->dev) below.
This is how device is freed after device_initialize().

<...>

> > +err_device:
> > +       put_device(&ucap->dev);
> > +unlock:
> > +       mutex_unlock(&ucaps_mutex);
> > +       return ret;
> > +}
> > +EXPORT_SYMBOL(ib_create_ucap);

<...>

> > +       ucaps_list[type] = NULL;
> > +       cdev_device_del(&ucap->cdev, &ucap->dev);
> > +       put_device(&ucap->dev);
> need to free ucap here

Same as above.

Thanks




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux