[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <YGFulvAa5Kz6HTsd@mwanda>
Date: Mon, 29 Mar 2021 09:07:18 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Andreas Noever <andreas.noever@...il.com>,
Kranthi Kuntala <kranthi.kuntala@...el.com>
Cc: Michael Jamet <michael.jamet@...el.com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Yehezkel Bernat <YehezkelShB@...il.com>,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org, Jason Gunthorpe <jgg@...dia.com>
Subject: [PATCH 1/2] thunderbolt: Fix a leak in tb_retimer_add()
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@...cle.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
Powered by blists - more mailing lists