[PATCH] softingcs: Fix memleak on registration failure in softingcs_probe

Miaoqian Lin posted 1 patch 4 years, 5 months ago
drivers/net/can/softing/softing_cs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] softingcs: Fix memleak on registration failure in softingcs_probe
Posted by Miaoqian Lin 4 years, 5 months ago
In case device registration fails during module initialisation, the
platform device structure needs to be freed using platform_device_put()
to properly free all resources (e.g. the device name).

Fixes: 0a0b7a5f7a04 ("can: add driver for Softing card")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/net/can/softing/softing_cs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/softing/softing_cs.c b/drivers/net/can/softing/softing_cs.c
index 2e93ee792373..e5c939b63fa6 100644
--- a/drivers/net/can/softing/softing_cs.c
+++ b/drivers/net/can/softing/softing_cs.c
@@ -293,7 +293,7 @@ static int softingcs_probe(struct pcmcia_device *pcmcia)
 	return 0;
 
 platform_failed:
-	kfree(dev);
+	platform_device_put(pdev);
 mem_failed:
 pcmcia_bad:
 pcmcia_failed:
-- 
2.17.1

Re: [PATCH] softingcs: Fix memleak on registration failure in softingcs_probe
Posted by Marc Kleine-Budde 4 years, 5 months ago
On 08.01.2022 09:25:51, Miaoqian Lin wrote:
> In case device registration fails during module initialisation, the
> platform device structure needs to be freed using platform_device_put()
> to properly free all resources (e.g. the device name).
> 
> Fixes: 0a0b7a5f7a04 ("can: add driver for Softing card")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Thanks for your patch, a similar one has already been posted: 

| https://lore.kernel.org/all/20211222104843.6105-1-johan@kernel.org/

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
Re: [PATCH] softingcs: Fix memleak on registration failure in softingcs_probe
Posted by patchwork-bot+netdevbpf@kernel.org 4 years, 5 months ago
Hello:

This patch was applied to netdev/net.git (master)
by Marc Kleine-Budde <mkl@pengutronix.de>:

On Sat,  8 Jan 2022 09:25:51 +0000 you wrote:
> In case device registration fails during module initialisation, the
> platform device structure needs to be freed using platform_device_put()
> to properly free all resources (e.g. the device name).
> 
> Fixes: 0a0b7a5f7a04 ("can: add driver for Softing card")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
> 
> [...]

Here is the summary with links:
  - softingcs: Fix memleak on registration failure in softingcs_probe
    https://git.kernel.org/netdev/net/c/ced4913efb0a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html