From: johann d. <jd...@us...> - 2002-03-20 21:43:28
|
Update of /cvsroot/linuxconsole/ruby/linux/drivers/input In directory usw-pr-cvs1:/tmp/cvs-serv9123 Modified Files: evdev.c joydev.c Log Message: Check that the device exists before accessing it (in writes, reads and ioctls). Index: evdev.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/input/evdev.c,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- evdev.c 3 Feb 2002 19:34:38 -0000 1.46 +++ evdev.c 20 Mar 2002 21:43:25 -0000 1.47 @@ -90,7 +90,9 @@ static int evdev_flush(struct file * file) { - return input_flush_device(&((struct evdev_list*)file->private_data)->evdev->handle, file); + struct evdev_list *list = (struct evdev_list*)file->private_data; + if (!list->evdev->exist) return -ENODEV; + return input_flush_device(&list->evdev->handle, file); } static int evdev_release(struct inode * inode, struct file * file) @@ -157,6 +159,8 @@ struct input_event event; int retval = 0; + if (!list->evdev->exist) return -ENODEV; + while (retval < count) { if (copy_from_user(&event, buffer + retval, sizeof(struct input_event))) @@ -230,6 +234,8 @@ struct evdev *evdev = list->evdev; struct input_dev *dev = evdev->handle.dev; int retval, t, u; + + if (!evdev->exist) return -ENODEV; switch (cmd) { Index: joydev.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/input/joydev.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- joydev.c 18 Mar 2002 19:29:10 -0000 1.41 +++ joydev.c 20 Mar 2002 21:43:25 -0000 1.42 @@ -254,6 +254,10 @@ while (list->head == list->tail) { + if (!joydev->exist) { + retval = -ENODEV; + break; + } if (file->f_flags & O_NONBLOCK) { retval = -EAGAIN; break; @@ -324,6 +328,8 @@ struct joydev *joydev = list->joydev; struct input_dev *dev = joydev->handle.dev; int i; + + if (!joydev->exist) return -ENODEV; switch (cmd) { |