HID: hidraw: fix hidraw_disconnect()
authorStefan Achatz <erazor_de@users.sourceforge.net>
Sat, 29 Jan 2011 01:17:30 +0000 (02:17 +0100)
committerJiri Kosina <jkosina@suse.cz>
Tue, 1 Feb 2011 10:16:51 +0000 (11:16 +0100)
hidraw_disconnect() first sets an entry in hidraw_table to NULL
and calls device_destroy() afterwards. The thereby called
hidraw_release() tries to read this already cleared value resulting
in never removing any device from the list.
This got fixed by changing the order of events.

Signed-off-by: Stefan Achatz <erazor_de@users.sourceforge.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hidraw.c

index 468e87b53ed26aadb86ed6b127599ea669a6aa99..5516ea45ce80f6ef0af9c27b81f5133ed8f29747 100644 (file)
@@ -428,12 +428,12 @@ void hidraw_disconnect(struct hid_device *hid)
 
        hidraw->exist = 0;
 
+       device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor));
+
        mutex_lock(&minors_lock);
        hidraw_table[hidraw->minor] = NULL;
        mutex_unlock(&minors_lock);
 
-       device_destroy(hidraw_class, MKDEV(hidraw_major, hidraw->minor));
-
        if (hidraw->open) {
                hid_hw_close(hid);
                wake_up_interruptible(&hidraw->wait);