Re: [PATCH v6 11/20] gpiolib: cdev: support GPIO_V2_LINE_SET_VALUES_IOCTL
From: Kent Gibson
Date: Thu Sep 03 2020 - 05:31:29 EST
On Thu, Sep 03, 2020 at 09:59:17AM +0200, Bartosz Golaszewski wrote:
> On Mon, Aug 31, 2020 at 5:23 AM Kent Gibson <warthog618@xxxxxxxxx> wrote:
> >
> > Add support for the GPIO_V2_LINE_SET_VALUES_IOCTL.
> >
> > Signed-off-by: Kent Gibson <warthog618@xxxxxxxxx>
> > ---
> > drivers/gpio/gpiolib-cdev.c | 59 +++++++++++++++++++++++++++++++++++++
> > 1 file changed, 59 insertions(+)
> >
> > diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
> > index 936b8c9958dd..9f05bbd2161e 100644
> > --- a/drivers/gpio/gpiolib-cdev.c
> > +++ b/drivers/gpio/gpiolib-cdev.c
> > @@ -777,6 +777,63 @@ static long linereq_get_values(struct linereq *lr, void __user *ip)
> > return 0;
> > }
> >
> > +static long linereq_set_values_unlocked(struct linereq *lr,
> > + struct gpio_v2_line_values *lv)
> > +{
> > + DECLARE_BITMAP(vals, GPIO_V2_LINES_MAX);
> > + struct gpio_desc **descs;
> > + unsigned int i, didx, num_set;
> > + int ret;
> > +
> > + bitmap_zero(vals, GPIO_V2_LINES_MAX);
> > + for (num_set = 0, i = 0; i < lr->num_lines; i++) {
> > + if (lv->mask & BIT_ULL(i)) {
> > + if (!test_bit(FLAG_IS_OUT, &lr->lines[i].desc->flags))
> > + return -EPERM;
> > + if (lv->bits & BIT_ULL(i))
> > + __set_bit(num_set, vals);
> > + num_set++;
> > + descs = &lr->lines[i].desc;
> > + }
> > + }
> > + if (num_set == 0)
> > + return -EINVAL;
> > +
> > + if (num_set != 1) {
> > + /* build compacted desc array and values */
> > + descs = kmalloc_array(num_set, sizeof(*descs), GFP_KERNEL);
>
> Missing retval check.
>
Arrgh, that has been there since PATCH v2!
And subsequently got propagated into patch 07 :-(.
Kent.