* [PATCH net] net: dsa: tag_8021q: avoid leaking ctx on dsa_tag_8021q_register() error path
@ 2022-12-09 23:52 Vladimir Oltean
2022-12-12 23:30 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Oltean @ 2022-12-09 23:52 UTC (permalink / raw)
To: netdev
Cc: Andrew Lunn, Florian Fainelli, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni
If dsa_tag_8021q_setup() fails, for example due to the inability of the
device to install a VLAN, the tag_8021q context of the switch will leak.
Make sure it is freed on the error path.
Fixes: 328621f6131f ("net: dsa: tag_8021q: absorb dsa_8021q_setup into dsa_tag_8021q_{,un}register")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
net/dsa/tag_8021q.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/net/dsa/tag_8021q.c b/net/dsa/tag_8021q.c
index b1263917fcb2..5ee9ef00954e 100644
--- a/net/dsa/tag_8021q.c
+++ b/net/dsa/tag_8021q.c
@@ -415,6 +415,7 @@ static void dsa_tag_8021q_teardown(struct dsa_switch *ds)
int dsa_tag_8021q_register(struct dsa_switch *ds, __be16 proto)
{
struct dsa_8021q_context *ctx;
+ int err;
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
if (!ctx)
@@ -427,7 +428,15 @@ int dsa_tag_8021q_register(struct dsa_switch *ds, __be16 proto)
ds->tag_8021q_ctx = ctx;
- return dsa_tag_8021q_setup(ds);
+ err = dsa_tag_8021q_setup(ds);
+ if (err)
+ goto err_free;
+
+ return 0;
+
+err_free:
+ kfree(ctx);
+ return err;
}
EXPORT_SYMBOL_GPL(dsa_tag_8021q_register);
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] net: dsa: tag_8021q: avoid leaking ctx on dsa_tag_8021q_register() error path
2022-12-09 23:52 [PATCH net] net: dsa: tag_8021q: avoid leaking ctx on dsa_tag_8021q_register() error path Vladimir Oltean
@ 2022-12-12 23:30 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-12-12 23:30 UTC (permalink / raw)
To: Vladimir Oltean; +Cc: netdev, andrew, f.fainelli, davem, edumazet, kuba, pabeni
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Sat, 10 Dec 2022 01:52:42 +0200 you wrote:
> If dsa_tag_8021q_setup() fails, for example due to the inability of the
> device to install a VLAN, the tag_8021q context of the switch will leak.
> Make sure it is freed on the error path.
>
> Fixes: 328621f6131f ("net: dsa: tag_8021q: absorb dsa_8021q_setup into dsa_tag_8021q_{,un}register")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
>
> [...]
Here is the summary with links:
- [net] net: dsa: tag_8021q: avoid leaking ctx on dsa_tag_8021q_register() error path
https://git.kernel.org/netdev/net/c/e095493091e8
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-12 23:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-09 23:52 [PATCH net] net: dsa: tag_8021q: avoid leaking ctx on dsa_tag_8021q_register() error path Vladimir Oltean
2022-12-12 23:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).