[PATCH v2] net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering

Subsystems: networking drivers, networking [dsa], ocelot ethernet switch driver, the rest

STALE1775d LANDED: 6 (6M)

1 review trailer (1 from subsystem maintainers); landed in mainline as e8b1d7698038 on 2021-12-09.

2 messages, 2 authors, 2021-12-09 · open the first message on its own page

[PATCH v2] net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering

From: José Expósito <hidden>
Date: 2021-12-09 11:06:17

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")
Signed-off-by: José Expósito <redacted>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

---

v2: Add Fixes and Reviewed-by tags
---
 drivers/net/dsa/ocelot/felix.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index 327cc4654806..f1a05e7dc818 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -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);
-- 
2.25.1

Re: [PATCH v2] net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering

From: patchwork-bot+netdevbpf@kernel.org
Date: 2021-12-09 16:20:15

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski [off-list ref]:

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")
Signed-off-by: José Expósito <redacted>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

[...]
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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help