Skip to contentSkip to conversation

drivers/usb/input/gtco.c: fix a use-before-check

PATCH New Adrian Bunk 1 participant 1 message Mar 19, 2007 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/usb/input/gtco.c: fix a use-before-check

NULL checks should be before the first dereference.

Spotted by the Coverity checker.

---

drivers/usb/input/gtco.c renamed from drivers/usb/input/gtco.c.old +1 -4
@@ -1047,13 +1047,10 @@ static void gtco_disconnect(struct usb_i
 
 	/* 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,