Drivers: hv: vmbus: Properly handle child device remove
authorK. Y. Srinivasan <kys@microsoft.com>
Sat, 28 Feb 2015 19:18:16 +0000 (11:18 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 Mar 2015 03:31:02 +0000 (19:31 -0800)
Handle the case when the device may be removed when the device has no driver
attached to it.

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hv/vmbus_drv.c

index 6d99aa5c49d6b60da62c153e3fb34553f53ff9f5..a12666d075ea65c2eed4210320d56d31140df4db 100644 (file)
@@ -508,14 +508,17 @@ static int vmbus_probe(struct device *child_device)
  */
 static int vmbus_remove(struct device *child_device)
 {
-       struct hv_driver *drv = drv_to_hv_drv(child_device->driver);
+       struct hv_driver *drv;
        struct hv_device *dev = device_to_hv_device(child_device);
 
-       if (drv->remove)
-               drv->remove(dev);
-       else
-               pr_err("remove not set for driver %s\n",
-                       dev_name(child_device));
+       if (child_device->driver) {
+               drv = drv_to_hv_drv(child_device->driver);
+               if (drv->remove)
+                       drv->remove(dev);
+               else
+                       pr_err("remove not set for driver %s\n",
+                               dev_name(child_device));
+       }
 
        return 0;
 }