Skip to content

Commit

Permalink
xen: xenbus: use put_device() instead of kfree()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arvind Yadav authored and Juergen Gross committed Mar 8, 2018
1 parent d811bce commit 351b2bc
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/xen/xenbus/xenbus_probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 351b2bc

Please sign in to comment.