linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen: xenbus: use put_device() instead of kfree()
@ 2018-03-06 10:10 Arvind Yadav
  2018-03-06 11:01 ` Juergen Gross
  2018-03-08 14:31 ` Juergen Gross
  0 siblings, 2 replies; 3+ messages in thread
From: Arvind Yadav @ 2018-03-06 10:10 UTC (permalink / raw)
  To: boris.ostrovsky, jgross; +Cc: linux-kernel, xen-devel

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>
---
 drivers/xen/xenbus/xenbus_probe.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
index 74888ca..ec9eb4f 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -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:
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xen: xenbus: use put_device() instead of kfree()
  2018-03-06 10:10 [PATCH] xen: xenbus: use put_device() instead of kfree() Arvind Yadav
@ 2018-03-06 11:01 ` Juergen Gross
  2018-03-08 14:31 ` Juergen Gross
  1 sibling, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2018-03-06 11:01 UTC (permalink / raw)
  To: Arvind Yadav, boris.ostrovsky; +Cc: linux-kernel, xen-devel

On 06/03/18 11:10, Arvind Yadav wrote:
> 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>


Juergen

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xen: xenbus: use put_device() instead of kfree()
  2018-03-06 10:10 [PATCH] xen: xenbus: use put_device() instead of kfree() Arvind Yadav
  2018-03-06 11:01 ` Juergen Gross
@ 2018-03-08 14:31 ` Juergen Gross
  1 sibling, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2018-03-08 14:31 UTC (permalink / raw)
  To: Arvind Yadav, boris.ostrovsky; +Cc: linux-kernel, xen-devel

On 06/03/18 11:10, Arvind Yadav wrote:
> 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>

Committed to xen/tip.git for-linus-4.16a


Juergen

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-03-08 14:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-06 10:10 [PATCH] xen: xenbus: use put_device() instead of kfree() Arvind Yadav
2018-03-06 11:01 ` Juergen Gross
2018-03-08 14:31 ` Juergen Gross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).