greybus: es1-ap-usb: don't use 'es1' after it is freed
authorViresh Kumar <viresh.kumar@linaro.org>
Mon, 24 Nov 2014 03:55:24 +0000 (09:25 +0530)
committerGreg Kroah-Hartman <greg@kroah.com>
Mon, 24 Nov 2014 21:54:45 +0000 (13:54 -0800)
greybus_remove_hd() will free memory allocated to 'es1' and so using it after
the routine has returned isn't right.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/es1-ap-usb.c

index bab6f25..2047843 100644 (file)
@@ -293,6 +293,7 @@ static int check_urb_status(struct urb *urb)
 static void ap_disconnect(struct usb_interface *interface)
 {
        struct es1_ap_dev *es1;
+       struct usb_device *udev;
        int i;
 
        es1 = usb_get_intfdata(interface);
@@ -329,9 +330,10 @@ static void ap_disconnect(struct usb_interface *interface)
        es1->svc_buffer = NULL;
 
        usb_set_intfdata(interface, NULL);
+       udev = es1->usb_dev;
        greybus_remove_hd(es1->hd);
 
-       usb_put_dev(es1->usb_dev);
+       usb_put_dev(udev);
 }
 
 /* Callback for when we get a SVC message */