diff mbox

[2/2] HID: hidraw, fix a NULL pointer dereference in hidraw_write

Message ID 1286292017-6746-3-git-send-email-ospite@studenti.unina.it (mailing list archive)
State Accepted
Commit e42dee9a99a3ecd32b5c027e8f7411fb5bc11eb6
Headers show

Commit Message

Antonio Ospite Oct. 5, 2010, 3:20 p.m. UTC
None
diff mbox

Patch

diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 9eaf6ae..a3866b5 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -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) {