lkml.org 
[lkml]   [2020]   [Sep]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6 11/20] gpiolib: cdev: support GPIO_V2_LINE_SET_VALUES_IOCTL
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@gmail.com> wrote:
> >
> > Add support for the GPIO_V2_LINE_SET_VALUES_IOCTL.
> >
> > Signed-off-by: Kent Gibson <warthog618@gmail.com>
> > ---
> > 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.

\
 
 \ /
  Last update: 2020-09-03 11:31    [W:0.066 / U:5.496 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site