summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorAntonio Ospite <ospite@studenti.unina.it>2010-10-05 17:20:16 +0200
committerGreg Kroah-Hartman <gregkh@suse.de>2010-10-28 21:51:07 -0700
commitdc7237c6b7b529c5da2776cbb8b68cc74d1555c3 (patch)
tree4095ef2b6a74961396a1890bb5fc543469380200 /drivers
parent6ce3cb681079d1f8274608b05d95b665fe66ed49 (diff)
HID: hidraw, fix a NULL pointer dereference in hidraw_ioctl
commit d20d5ffab92f00188f360c44c791a5ffb988247c upstream. BUG: unable to handle kernel NULL pointer dereference at 0000000000000028 IP: [<ffffffffa02c66b4>] hidraw_ioctl+0xfc/0x32c [hid] [...] This is reproducible by disconnecting the device while userspace does ioctl in a loop and doesn't check return values in order to exit the loop. Signed-off-by: Antonio Ospite <ospite@studenti.unina.it> Signed-off-by: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hid/hidraw.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 3ccd47850677..f43e95e11d48 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -246,6 +246,10 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
mutex_lock(&minors_lock);
dev = hidraw_table[minor];
+ if (!dev) {
+ ret = -ENODEV;
+ goto out;
+ }
switch (cmd) {
case HIDIOCGRDESCSIZE:
@@ -319,6 +323,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd,
ret = -ENOTTY;
}
+out:
mutex_unlock(&minors_lock);
return ret;
}