linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] thunderbolt: Fix a leak in tb_retimer_add()
@ 2021-03-29  6:07 Dan Carpenter
  2021-03-29  6:08 ` [PATCH 2/2] thunderbolt: Fix off by one in tb_port_find_retimer() Dan Carpenter
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Dan Carpenter @ 2021-03-29  6:07 UTC (permalink / raw)
  To: Andreas Noever, Kranthi Kuntala
  Cc: Michael Jamet, Mika Westerberg, Yehezkel Bernat, linux-usb,
	linux-kernel, kernel-janitors, Jason Gunthorpe

After the device_register() succeeds, then the correct way to clean up
is to call device_unregister().  The unregister calls both device_del()
and device_put().  Since this code was only device_del() it results in
a memory leak.

Fixes: dacb12877d92 ("thunderbolt: Add support for on-board retimers")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This is from a new static checker warning.  Not tested.  With new
warnings it's also possible that I have misunderstood something
fundamental so review carefully etc.

 drivers/thunderbolt/retimer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thunderbolt/retimer.c b/drivers/thunderbolt/retimer.c
index 620bcf586ee2..7a5d61604c8b 100644
--- a/drivers/thunderbolt/retimer.c
+++ b/drivers/thunderbolt/retimer.c
@@ -347,7 +347,7 @@ static int tb_retimer_add(struct tb_port *port, u8 index, u32 auth_status)
 	ret = tb_retimer_nvm_add(rt);
 	if (ret) {
 		dev_err(&rt->dev, "failed to add NVM devices: %d\n", ret);
-		device_del(&rt->dev);
+		device_unregister(&rt->dev);
 		return ret;
 	}
 
-- 
2.30.2


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

end of thread, other threads:[~2021-03-30 10:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-29  6:07 [PATCH 1/2] thunderbolt: Fix a leak in tb_retimer_add() Dan Carpenter
2021-03-29  6:08 ` [PATCH 2/2] thunderbolt: Fix off by one in tb_port_find_retimer() Dan Carpenter
2021-03-29 13:02 ` [PATCH 1/2] thunderbolt: Fix a leak in tb_retimer_add() Jason Gunthorpe
2021-03-29 14:43   ` Mika Westerberg
2021-03-29 14:54     ` Jason Gunthorpe
2021-03-29 15:06       ` Mika Westerberg
2021-03-30 10:41 ` Mika Westerberg

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).