Skip to content

Commit

Permalink
HID: hidraw, fix a NULL pointer dereference in hidraw_write
Browse files Browse the repository at this point in the history
BUG: unable to handle kernel NULL pointer dereference at 0000000000000028
IP: [<ffffffffa0f0a625>] hidraw_write+0x3b/0x116 [hid]
[...]

This is reproducible by disconnecting the device while userspace writes
to dev node in a loop and doesn't check return values in order to exit
the loop.

Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
Cc: stable@kernel.org
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
Antonio Ospite authored and Jiri Kosina committed Oct 6, 2010
1 parent d20d5ff commit e42dee9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/hid/hidraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t
int ret = 0;

mutex_lock(&minors_lock);

if (!hidraw_table[minor]) {
ret = -ENODEV;
goto out;
}

dev = hidraw_table[minor]->hid;

if (!dev->hid_output_raw_report) {
Expand Down

0 comments on commit e42dee9

Please sign in to comment.