Skip to content

Commit a955358

Browse files
rodrigorcJiri Kosina
authored andcommitted
HID: hidraw: Fix crash on HIDIOCGFEATURE with a destroyed device
Doing `ioctl(HIDIOCGFEATURE)` in a tight loop on a hidraw device and then disconnecting the device, or unloading the driver, can cause a NULL pointer dereference. When a hidraw device is destroyed it sets 0 to `dev->exist`. Most functions check 'dev->exist' before doing its work, but `hidraw_get_report()` was missing that check. Cc: [email protected] Signed-off-by: Rodrigo Rivas Costa <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 2e210bb commit a955358

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/hid/hidraw.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
192192
int ret = 0, len;
193193
unsigned char report_number;
194194

195+
if (!hidraw_table[minor] || !hidraw_table[minor]->exist) {
196+
ret = -ENODEV;
197+
goto out;
198+
}
199+
195200
dev = hidraw_table[minor]->hid;
196201

197202
if (!dev->ll_driver->raw_request) {

0 commit comments

Comments
 (0)