USB: gtco.c: fix a use-before-check
authorAdrian Bunk <bunk@stusta.de>
Mon, 19 Mar 2007 09:26:32 +0000 (10:26 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 27 Apr 2007 20:28:36 +0000 (13:28 -0700)
NULL checks should be before the first dereference.

Spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/input/gtco.c

index 203cdc1bbba442806b29d90806be6a20dafb5c03..ae756e0afc996fd5d50d1192a7c062bc3a38145f 100644 (file)
@@ -1047,13 +1047,10 @@ static void gtco_disconnect(struct usb_interface *interface)
 
        /* Grab private device ptr */
        struct gtco    *device = usb_get_intfdata (interface);
-       struct input_dev *inputdev;
-
-       inputdev = device->inputdevice;
 
        /* Now reverse all the registration stuff */
        if (device) {
-               input_unregister_device(inputdev);
+               input_unregister_device(device->inputdevice);
                usb_kill_urb(device->urbinfo);
                usb_free_urb(device->urbinfo);
                usb_buffer_free(device->usbdev, REPORT_MAX_SIZE,