greybus: hd: fix host-device-removal race
authorJohan Hovold <johan@hovoldconsulting.com>
Thu, 28 Jan 2016 11:43:29 +0000 (12:43 +0100)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 28 Jan 2016 16:10:56 +0000 (08:10 -0800)
Make sure to tear down the svc and flush any on-going hotplug processing
before removing the remaining interfaces.

This fixes crashes due to host-device removal racing with svc
hotplug/unplug processing (e.g. at "UniPro restart").

Testing Done:
Verified that this fixes crashes reproducible on SDB when unloading the
host-device driver module while generating hotplug/unplug events.

Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/hd.c

index b11a6364423595b987cc59011a342040f78d4258..d1aab29d3da4ed8371247623c1996a2c8721f5c4 100644 (file)
@@ -135,9 +135,12 @@ EXPORT_SYMBOL_GPL(gb_hd_add);
 
 void gb_hd_del(struct gb_host_device *hd)
 {
-       gb_interfaces_remove(hd);
-
+       /*
+        * Tear down the svc and flush any on-going hotplug processing before
+        * removing the remaining interfaces.
+        */
        gb_svc_del(hd->svc);
+       gb_interfaces_remove(hd);
 
        device_del(&hd->dev);
 }