diff options
Diffstat (limited to 'drivers/hid/hidraw.c')
-rw-r--r-- | drivers/hid/hidraw.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 47d70c523d93..a3866b5c0c43 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 | |||
109 | int ret = 0; | 109 | int ret = 0; |
110 | 110 | ||
111 | mutex_lock(&minors_lock); | 111 | mutex_lock(&minors_lock); |
112 | |||
113 | if (!hidraw_table[minor]) { | ||
114 | ret = -ENODEV; | ||
115 | goto out; | ||
116 | } | ||
117 | |||
112 | dev = hidraw_table[minor]->hid; | 118 | dev = hidraw_table[minor]->hid; |
113 | 119 | ||
114 | if (!dev->hid_output_raw_report) { | 120 | if (!dev->hid_output_raw_report) { |
@@ -244,6 +250,10 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, | |||
244 | 250 | ||
245 | mutex_lock(&minors_lock); | 251 | mutex_lock(&minors_lock); |
246 | dev = hidraw_table[minor]; | 252 | dev = hidraw_table[minor]; |
253 | if (!dev) { | ||
254 | ret = -ENODEV; | ||
255 | goto out; | ||
256 | } | ||
247 | 257 | ||
248 | switch (cmd) { | 258 | switch (cmd) { |
249 | case HIDIOCGRDESCSIZE: | 259 | case HIDIOCGRDESCSIZE: |
@@ -317,6 +327,7 @@ static long hidraw_ioctl(struct file *file, unsigned int cmd, | |||
317 | 327 | ||
318 | ret = -ENOTTY; | 328 | ret = -ENOTTY; |
319 | } | 329 | } |
330 | out: | ||
320 | mutex_unlock(&minors_lock); | 331 | mutex_unlock(&minors_lock); |
321 | return ret; | 332 | return ret; |
322 | } | 333 | } |