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 74888cacd0b0bdcd250135e6436e0c1e39fc330f..ec9eb4fba59c7e88f746f01aa9fe66c2ed590482 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: