xen: xenbus: use put_device() instead of kfree()
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Tue, 6 Mar 2018 10:10:37 +0000 (15:40 +0530)
committerJuergen Gross <jgross@suse.com>
Thu, 8 Mar 2018 14:30:30 +0000 (15:30 +0100)
Never directly free @dev after calling device_register(), even
if it returned an error! Always use put_device() to give up the
reference initialized.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
drivers/xen/xenbus/xenbus_probe.c

index 74888ca..ec9eb4f 100644 (file)
@@ -466,8 +466,11 @@ int xenbus_probe_node(struct xen_bus_type *bus,
 
        /* Register with generic device framework. */
        err = device_register(&xendev->dev);
-       if (err)
+       if (err) {
+               put_device(&xendev->dev);
+               xendev = NULL;
                goto fail;
+       }
 
        return 0;
 fail: