Skip to contentSkip to conversation

net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering

PATCH Applied José Expósito 2 participants 2 messages Dec 9, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering

Avoid a memory leak if there is not a CPU port defined.

Fixes 8d5f7954b7c8 ("net: dsa: felix: break at first CPU port during init and teardown")

Addresses-Coverity-ID: 1492897 ("Resource leak")
Addresses-Coverity-ID: 1492899 ("Resource leak")

---

v2: Add Fixes and Reviewed-by tags

---
 drivers/net/dsa/ocelot/felix.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/dsa/ocelot/felix.c +4 -1
index 327cc4654806..f1a05e7dc818 100644
@@ -290,8 +290,11 @@ static int felix_setup_mmio_filtering(struct felix *felix)
 		}
 	}
 
-	if (cpu < 0)
+	if (cpu < 0) {
+		kfree(tagging_rule);
+		kfree(redirect_rule);
 		return -EINVAL;
+	}
 
 	tagging_rule->key_type = OCELOT_VCAP_KEY_ETYPE;
 	*(__be16 *)tagging_rule->key.etype.etype.value = htons(ETH_P_1588);
Signature · 1 line
2.25.1
#1 lore raw
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 9 lines · On Thu, 9 Dec 2021 12:05:40 +0100 you wrote:

Avoid a memory leak if there is not a CPU port defined.

Fixes 8d5f7954b7c8 ("net: dsa: felix: break at first CPU port during init and teardown")

Addresses-Coverity-ID: 1492897 ("Resource leak")
Addresses-Coverity-ID: 1492899 ("Resource leak")

[...]

Here is the summary with links:
- [v2] net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering

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

You are awesome, thank you!

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