Skip to content

Commit

Permalink
xen: xenbus: use put_device() instead of kfree()
Browse files Browse the repository at this point in the history
[ Upstream commit 351b2bc ]

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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Arvind Yadav authored and Greg Kroah-Hartman committed May 30, 2018
1 parent db57535 commit 7f4ac64
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 @@ -470,8 +470,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 7f4ac64

Please sign in to comment.