From: Johan Hovold Date: Thu, 28 Jan 2016 11:43:29 +0000 (+0100) Subject: greybus: hd: fix host-device-removal race X-Git-Tag: v4.9-rc1~119^2~378^2~21^2~743 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=24988d3a253303be63c460071dd99bd4674c0880;p=karo-tx-linux.git greybus: hd: fix host-device-removal race 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/hd.c b/drivers/staging/greybus/hd.c index b11a63644235..d1aab29d3da4 100644 --- a/drivers/staging/greybus/hd.c +++ b/drivers/staging/greybus/hd.c @@ -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); }