Skip to content

Commit

Permalink
staging:iio:events: Make sure userspace buffer is large enough
Browse files Browse the repository at this point in the history
Make sure that the userspace buffer is large enough to hold a iio_event_data
struct before writing to it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Lars-Peter Clausen authored and Greg Kroah-Hartman committed Nov 27, 2011
1 parent 0403e0d commit dc8f526
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/staging/iio/industrialio-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,11 @@ static ssize_t iio_event_chrdev_read(struct file *filep,
{
struct iio_event_interface *ev_int = filep->private_data;
struct iio_detected_event_list *el;
size_t len = sizeof(el->ev);
int ret;
size_t len;

if (count < len)
return -EINVAL;

mutex_lock(&ev_int->event_list_lock);
if (list_empty(&ev_int->det_events)) {
Expand All @@ -192,7 +195,6 @@ static ssize_t iio_event_chrdev_read(struct file *filep,
el = list_first_entry(&ev_int->det_events,
struct iio_detected_event_list,
list);
len = sizeof el->ev;
if (copy_to_user(buf, &(el->ev), len)) {
ret = -EFAULT;
goto error_mutex_unlock;
Expand Down

0 comments on commit dc8f526

Please sign in to comment.