* [PATCH] net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering
@ 2021-12-08 18:05 José Expósito
2021-12-08 18:13 ` Vladimir Oltean
0 siblings, 1 reply; 4+ messages in thread
From: José Expósito @ 2021-12-08 18:05 UTC (permalink / raw)
To: vladimir.oltean
Cc: claudiu.manoil, alexandre.belloni, andrew, vivien.didelot,
f.fainelli, davem, kuba, linux, netdev, linux-kernel,
José Expósito
Addresses-Coverity-ID: 1492897 ("Resource leak")
Addresses-Coverity-ID: 1492899 ("Resource leak")
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering
2021-12-08 18:05 [PATCH] net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering José Expósito
@ 2021-12-08 18:13 ` Vladimir Oltean
2021-12-08 23:10 ` Jakub Kicinski
0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Oltean @ 2021-12-08 18:13 UTC (permalink / raw)
To: José Expósito
Cc: Claudiu Manoil, alexandre.belloni, andrew, vivien.didelot,
f.fainelli, davem, kuba, linux, netdev, linux-kernel
On Wed, Dec 08, 2021 at 07:05:09PM +0100, José Expósito wrote:
> Addresses-Coverity-ID: 1492897 ("Resource leak")
> Addresses-Coverity-ID: 1492899 ("Resource leak")
> Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> ---
Impossible memory leak, I might add, because DSA will error out much
soon if there isn't any CPU port defined:
https://elixir.bootlin.com/linux/v5.15.7/source/net/dsa/dsa2.c#L374
I don't think I should have added the "if (cpu < 0)" check at all, but
then it would have raised other flags, about BIT(negative number) or
things like that. I don't know what's the best way to deal with this?
Anyway, in case we find no better alternative:
Fixes: 8d5f7954b7c8 ("net: dsa: felix: break at first CPU port during init and teardown")
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> 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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering
2021-12-08 18:13 ` Vladimir Oltean
@ 2021-12-08 23:10 ` Jakub Kicinski
2021-12-09 11:09 ` José Expósito
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2021-12-08 23:10 UTC (permalink / raw)
To: José Expósito
Cc: Vladimir Oltean, Claudiu Manoil, alexandre.belloni, andrew,
vivien.didelot, f.fainelli, davem, linux, netdev, linux-kernel
On Wed, 8 Dec 2021 18:13:32 +0000 Vladimir Oltean wrote:
> On Wed, Dec 08, 2021 at 07:05:09PM +0100, José Expósito wrote:
> > Addresses-Coverity-ID: 1492897 ("Resource leak")
> > Addresses-Coverity-ID: 1492899 ("Resource leak")
> > Signed-off-by: José Expósito <jose.exposito89@gmail.com>
> > ---
>
> Impossible memory leak, I might add, because DSA will error out much
> soon if there isn't any CPU port defined:
> https://elixir.bootlin.com/linux/v5.15.7/source/net/dsa/dsa2.c#L374
> I don't think I should have added the "if (cpu < 0)" check at all, but
> then it would have raised other flags, about BIT(negative number) or
> things like that. I don't know what's the best way to deal with this?
>
> Anyway, in case we find no better alternative:
>
> Fixes: 8d5f7954b7c8 ("net: dsa: felix: break at first CPU port during init and teardown")
> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
If this is the way to go please repost with the tags added
and a commit message.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering
2021-12-08 23:10 ` Jakub Kicinski
@ 2021-12-09 11:09 ` José Expósito
0 siblings, 0 replies; 4+ messages in thread
From: José Expósito @ 2021-12-09 11:09 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Vladimir Oltean, Claudiu Manoil, alexandre.belloni, andrew,
vivien.didelot, f.fainelli, davem, linux, netdev, linux-kernel
On Wed, Dec 08, 2021 at 03:10:30PM -0800, Jakub Kicinski wrote:
> On Wed, 8 Dec 2021 18:13:32 +0000 Vladimir Oltean wrote:
> > Impossible memory leak, I might add, because DSA will error out much
> > soon if there isn't any CPU port defined:
> > https://elixir.bootlin.com/linux/v5.15.7/source/net/dsa/dsa2.c#L374
> > I don't think I should have added the "if (cpu < 0)" check at all, but
> > then it would have raised other flags, about BIT(negative number) or
> > things like that. I don't know what's the best way to deal with this?
> >
> > Anyway, in case we find no better alternative:
> >
> > Fixes: 8d5f7954b7c8 ("net: dsa: felix: break at first CPU port during init and teardown")
> > Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
>
> If this is the way to go please repost with the tags added
> and a commit message.
Thanks for the quick review. I just sent v2 in case you decide to keep
the cpu check:
https://lore.kernel.org/netdev/20211209110538.11585-1-jose.exposito89@gmail.com/T/#u
Jose
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-09 11:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-08 18:05 [PATCH] net: dsa: felix: Fix memory leak in felix_setup_mmio_filtering José Expósito
2021-12-08 18:13 ` Vladimir Oltean
2021-12-08 23:10 ` Jakub Kicinski
2021-12-09 11:09 ` José Expósito
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).