Re: possible missing error handling in hidraw

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

 



On Fri, 27 Apr 2012, Oliver Neukum wrote:

> > -void hidraw_report_event(struct hid_device *hid, u8 *data, int len)
> > +int hidraw_report_event(struct hid_device *hid, u8 *data, int len)
> >  {
> >         struct hidraw *dev = hid->hidraw;
> >         struct hidraw_list *list;
> > +       int ret = 0;
> >  
> >         list_for_each_entry(list, &dev->list, node) {
> > -               list->buffer[list->head].value = kmemdup(data, len, GFP_ATOMIC);
> > +               if (!(list->buffer[list->head].value = kmemdup(data, len, GFP_ATOMIC))) {
> > +                       ret = -ENOMEM;
> > +                       break;
> > +               }
> >                 list->buffer[list->head].len = len;
> >                 list->head = (list->head + 1) & (HIDRAW_BUFFER_SIZE - 1);
> >                 kill_fasync(&list->fasync, SIGIO, POLL_IN);
> >         }
> >  
> >         wake_up_interruptible(&dev->wait);
> > +       return ret;
> >  }
> 
> Then I have to ask why not simply copy the rest of the entries?

Well, it's sort of inconsistent in both scenarios ...

-- 
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux