Skip to contentSkip to conversation

ptp_qoriq: fix memory leak in probe()

PATCH Applied SongJingyi 2 participants 2 messages Mar 24, 2023 – Mar 25, 2023

Subsystems (4)
lore
Share & tools
lore

SongJingyi

author
#0 lore raw

PATCH 1/1 ptp_qoriq: fix memory leak in probe()

Smatch complains that:
drivers/ptp/ptp_qoriq.c ptp_qoriq_probe()
warn: 'base' from ioremap() not released.

Fix this by revising the parameter from 'ptp_qoriq->base' to 'base'. This is only a bug if ptp_qoriq_init() returns on the first -ENODEV error path.
For other error paths ptp_qoriq->base and base are the same. And this change makes the code more readable.

Fixes 7f4399ba405b ("ptp_qoriq: fix NULL access if ptp dt node missing")
---
 drivers/ptp/ptp_qoriq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ptp/ptp_qoriq.c +1 -1
index 61530167efe4..350154e4c2b5 100644
@@ -637,7 +637,7 @@ static int ptp_qoriq_probe(struct platform_device *dev)
 	return 0;
 
 no_clock:
-	iounmap(ptp_qoriq->base);
+	iounmap(base);
 no_ioremap:
 	release_resource(ptp_qoriq->rsrc);
 no_resource:
Signature · 1 line
2.34.1
#1 lore raw
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Fri, 24 Mar 2023 11:14:06 +0800 you wrote:

Smatch complains that:
drivers/ptp/ptp_qoriq.c ptp_qoriq_probe()
warn: 'base' from ioremap() not released.

Fix this by revising the parameter from 'ptp_qoriq->base' to 'base'. This is only a bug if ptp_qoriq_init() returns on the first -ENODEV error path.
For other error paths ptp_qoriq->base and base are the same. And this change makes the code more readable.

[...]

Here is the summary with links:
- ptp_qoriq: fix memory leak in probe()

    https://git.kernel.org/netdev/net/c/f33642224e38

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html