* [PATCH] net: dsa: sja1105: prevent leaking memory
@ 2019-09-18 17:10 Navid Emamdoost
2019-09-18 17:21 ` Andrew Lunn
0 siblings, 1 reply; 9+ messages in thread
From: Navid Emamdoost @ 2019-09-18 17:10 UTC (permalink / raw)
Cc: emamd001, smccaman, kjlu, Navid Emamdoost, Vladimir Oltean,
Andrew Lunn, Vivien Didelot, Florian Fainelli, David S. Miller,
linux-kernel, netdev
In sja1105_static_config_upload, in two cases memory is leaked: when
static_config_buf_prepare_for_upload fails and when sja1105_inhibit_tx
fails. In both cases config_buf should be released.
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
drivers/net/dsa/sja1105/sja1105_spi.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/net/dsa/sja1105/sja1105_spi.c b/drivers/net/dsa/sja1105/sja1105_spi.c
index 84dc603138cf..80e86c714efb 100644
--- a/drivers/net/dsa/sja1105/sja1105_spi.c
+++ b/drivers/net/dsa/sja1105/sja1105_spi.c
@@ -408,8 +408,9 @@ int sja1105_static_config_upload(struct sja1105_private *priv)
rc = static_config_buf_prepare_for_upload(priv, config_buf, buf_len);
if (rc < 0) {
- dev_err(dev, "Invalid config, cannot upload\n");
- return -EINVAL;
+ dev_err(dev, "Invalid config, cannot upload\n");
+ rc = -EINVAL;
+ goto out;
}
/* Prevent PHY jabbering during switch reset by inhibiting
* Tx on all ports and waiting for current packet to drain.
@@ -418,7 +419,8 @@ int sja1105_static_config_upload(struct sja1105_private *priv)
rc = sja1105_inhibit_tx(priv, port_bitmap, true);
if (rc < 0) {
dev_err(dev, "Failed to inhibit Tx on ports\n");
- return -ENXIO;
+ rc = -ENXIO;
+ goto out;
}
/* Wait for an eventual egress packet to finish transmission
* (reach IFG). It is guaranteed that a second one will not
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] net: dsa: sja1105: prevent leaking memory
2019-09-18 17:10 [PATCH] net: dsa: sja1105: prevent leaking memory Navid Emamdoost
@ 2019-09-18 17:21 ` Andrew Lunn
2019-09-18 18:04 ` [PATCH v2] " Navid Emamdoost
0 siblings, 1 reply; 9+ messages in thread
From: Andrew Lunn @ 2019-09-18 17:21 UTC (permalink / raw)
To: Navid Emamdoost
Cc: emamd001, smccaman, kjlu, Vladimir Oltean, Vivien Didelot,
Florian Fainelli, David S. Miller, linux-kernel, netdev
On Wed, Sep 18, 2019 at 12:10:19PM -0500, Navid Emamdoost wrote:
> In sja1105_static_config_upload, in two cases memory is leaked: when
> static_config_buf_prepare_for_upload fails and when sja1105_inhibit_tx
> fails. In both cases config_buf should be released.
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Hi Navid
Please could you provide a Fixes: tag for where this memory leak was
introduced.
> ---
> drivers/net/dsa/sja1105/sja1105_spi.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/dsa/sja1105/sja1105_spi.c b/drivers/net/dsa/sja1105/sja1105_spi.c
> index 84dc603138cf..80e86c714efb 100644
> --- a/drivers/net/dsa/sja1105/sja1105_spi.c
> +++ b/drivers/net/dsa/sja1105/sja1105_spi.c
> @@ -408,8 +408,9 @@ int sja1105_static_config_upload(struct sja1105_private *priv)
>
> rc = static_config_buf_prepare_for_upload(priv, config_buf, buf_len);
> if (rc < 0) {
> - dev_err(dev, "Invalid config, cannot upload\n");
> - return -EINVAL;
> + dev_err(dev, "Invalid config, cannot upload\n");
What changed in this dev_err() call?
Thanks
Andrew
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2] net: dsa: sja1105: prevent leaking memory
2019-09-18 17:21 ` Andrew Lunn
@ 2019-09-18 18:04 ` Navid Emamdoost
2019-09-18 20:00 ` Vladimir Oltean
0 siblings, 1 reply; 9+ messages in thread
From: Navid Emamdoost @ 2019-09-18 18:04 UTC (permalink / raw)
To: andrew
Cc: emamd001, smccaman, kjlu, Navid Emamdoost, Vladimir Oltean,
Vivien Didelot, Florian Fainelli, David S. Miller, linux-kernel,
netdev
In sja1105_static_config_upload, in two cases memory is leaked: when
static_config_buf_prepare_for_upload fails and when sja1105_inhibit_tx
fails. In both cases config_buf should be released.
Fixes: 8aa9ebccae876 (avoid leaking config_buf)
Fixes: 1a4c69406cc1c (avoid leaking config_buf)
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
drivers/net/dsa/sja1105/sja1105_spi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/sja1105/sja1105_spi.c b/drivers/net/dsa/sja1105/sja1105_spi.c
index 84dc603138cf..58dd37ecde17 100644
--- a/drivers/net/dsa/sja1105/sja1105_spi.c
+++ b/drivers/net/dsa/sja1105/sja1105_spi.c
@@ -409,7 +409,8 @@ int sja1105_static_config_upload(struct sja1105_private *priv)
rc = static_config_buf_prepare_for_upload(priv, config_buf, buf_len);
if (rc < 0) {
dev_err(dev, "Invalid config, cannot upload\n");
- return -EINVAL;
+ rc = -EINVAL;
+ goto out;
}
/* Prevent PHY jabbering during switch reset by inhibiting
* Tx on all ports and waiting for current packet to drain.
@@ -418,7 +419,8 @@ int sja1105_static_config_upload(struct sja1105_private *priv)
rc = sja1105_inhibit_tx(priv, port_bitmap, true);
if (rc < 0) {
dev_err(dev, "Failed to inhibit Tx on ports\n");
- return -ENXIO;
+ rc = -ENXIO;
+ goto out;
}
/* Wait for an eventual egress packet to finish transmission
* (reach IFG). It is guaranteed that a second one will not
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2] net: dsa: sja1105: prevent leaking memory
2019-09-18 18:04 ` [PATCH v2] " Navid Emamdoost
@ 2019-09-18 20:00 ` Vladimir Oltean
2019-09-18 20:34 ` [PATCH v3] " Navid Emamdoost
2019-09-19 8:10 ` [PATCH v2] " David Miller
0 siblings, 2 replies; 9+ messages in thread
From: Vladimir Oltean @ 2019-09-18 20:00 UTC (permalink / raw)
To: Navid Emamdoost, andrew
Cc: emamd001, smccaman, kjlu, Vivien Didelot, Florian Fainelli,
David S. Miller, linux-kernel, netdev
Hi Navid,
Thanks for the patch.
On 9/18/19 9:04 PM, Navid Emamdoost wrote:
> In sja1105_static_config_upload, in two cases memory is leaked: when
> static_config_buf_prepare_for_upload fails and when sja1105_inhibit_tx
> fails. In both cases config_buf should be released.
>
> Fixes: 8aa9ebccae876 (avoid leaking config_buf)
> Fixes: 1a4c69406cc1c (avoid leaking config_buf)
>
You're not supposed to add a short description of the patch here, but
rather the commit message of the patch you're fixing.
Add this to your ~/.gitconfig:
[pretty]
fixes = Fixes: %h (\"%s\")
And then run:
git show --pretty=fixes 8aa9ebccae87621d997707e4f25e53fddd7e30e4
Fixes: 8aa9ebccae87 ("net: dsa: Introduce driver for NXP SJA1105 5-port
L2 switch")
git show --pretty=fixes 1a4c69406cc1c3c42bb7391c8eb544e93fe9b320
Fixes: 1a4c69406cc1 ("net: dsa: sja1105: Prevent PHY jabbering during
switch reset")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
> drivers/net/dsa/sja1105/sja1105_spi.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/dsa/sja1105/sja1105_spi.c b/drivers/net/dsa/sja1105/sja1105_spi.c
> index 84dc603138cf..58dd37ecde17 100644
> --- a/drivers/net/dsa/sja1105/sja1105_spi.c
> +++ b/drivers/net/dsa/sja1105/sja1105_spi.c
> @@ -409,7 +409,8 @@ int sja1105_static_config_upload(struct sja1105_private *priv)
> rc = static_config_buf_prepare_for_upload(priv, config_buf, buf_len);
> if (rc < 0) {
> dev_err(dev, "Invalid config, cannot upload\n");
> - return -EINVAL;
> + rc = -EINVAL;
> + goto out;
> }
> /* Prevent PHY jabbering during switch reset by inhibiting
> * Tx on all ports and waiting for current packet to drain.
> @@ -418,7 +419,8 @@ int sja1105_static_config_upload(struct sja1105_private *priv)
> rc = sja1105_inhibit_tx(priv, port_bitmap, true);
> if (rc < 0) {
> dev_err(dev, "Failed to inhibit Tx on ports\n");
> - return -ENXIO;
> + rc = -ENXIO;
> + goto out;
> }
> /* Wait for an eventual egress packet to finish transmission
> * (reach IFG). It is guaranteed that a second one will not
>
Regards,
-Vladimir
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3] net: dsa: sja1105: prevent leaking memory
2019-09-18 20:00 ` Vladimir Oltean
@ 2019-09-18 20:34 ` Navid Emamdoost
2019-09-18 20:40 ` Vladimir Oltean
2019-09-19 8:13 ` David Miller
2019-09-19 8:10 ` [PATCH v2] " David Miller
1 sibling, 2 replies; 9+ messages in thread
From: Navid Emamdoost @ 2019-09-18 20:34 UTC (permalink / raw)
To: olteanv
Cc: emamd001, smccaman, kjlu, Navid Emamdoost, Andrew Lunn,
Vivien Didelot, Florian Fainelli, David S. Miller, linux-kernel,
netdev
In sja1105_static_config_upload, in two cases memory is leaked: when
static_config_buf_prepare_for_upload fails and when sja1105_inhibit_tx
fails. In both cases config_buf should be released.
Fixes: 8aa9ebccae87 ("net: dsa: Introduce driver for NXP SJA1105 5-port
L2 switch")
Fixes: 1a4c69406cc1 ("net: dsa: sja1105: Prevent PHY jabbering during
switch reset")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
drivers/net/dsa/sja1105/sja1105_spi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/sja1105/sja1105_spi.c b/drivers/net/dsa/sja1105/sja1105_spi.c
index 84dc603138cf..58dd37ecde17 100644
--- a/drivers/net/dsa/sja1105/sja1105_spi.c
+++ b/drivers/net/dsa/sja1105/sja1105_spi.c
@@ -409,7 +409,8 @@ int sja1105_static_config_upload(struct sja1105_private *priv)
rc = static_config_buf_prepare_for_upload(priv, config_buf, buf_len);
if (rc < 0) {
dev_err(dev, "Invalid config, cannot upload\n");
- return -EINVAL;
+ rc = -EINVAL;
+ goto out;
}
/* Prevent PHY jabbering during switch reset by inhibiting
* Tx on all ports and waiting for current packet to drain.
@@ -418,7 +419,8 @@ int sja1105_static_config_upload(struct sja1105_private *priv)
rc = sja1105_inhibit_tx(priv, port_bitmap, true);
if (rc < 0) {
dev_err(dev, "Failed to inhibit Tx on ports\n");
- return -ENXIO;
+ rc = -ENXIO;
+ goto out;
}
/* Wait for an eventual egress packet to finish transmission
* (reach IFG). It is guaranteed that a second one will not
--
2.17.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3] net: dsa: sja1105: prevent leaking memory
2019-09-18 20:34 ` [PATCH v3] " Navid Emamdoost
@ 2019-09-18 20:40 ` Vladimir Oltean
2019-09-19 8:13 ` David Miller
1 sibling, 0 replies; 9+ messages in thread
From: Vladimir Oltean @ 2019-09-18 20:40 UTC (permalink / raw)
To: Navid Emamdoost
Cc: Navid Emamdoost, Stephen McCamant, kjlu, Andrew Lunn,
Vivien Didelot, Florian Fainelli, David S. Miller, lkml, netdev
On Wed, 18 Sep 2019 at 23:34, Navid Emamdoost <navid.emamdoost@gmail.com> wrote:
>
> In sja1105_static_config_upload, in two cases memory is leaked: when
> static_config_buf_prepare_for_upload fails and when sja1105_inhibit_tx
> fails. In both cases config_buf should be released.
>
> Fixes: 8aa9ebccae87 ("net: dsa: Introduce driver for NXP SJA1105 5-port
> L2 switch")
>
> Fixes: 1a4c69406cc1 ("net: dsa: sja1105: Prevent PHY jabbering during
> switch reset")
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
> drivers/net/dsa/sja1105/sja1105_spi.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/dsa/sja1105/sja1105_spi.c b/drivers/net/dsa/sja1105/sja1105_spi.c
> index 84dc603138cf..58dd37ecde17 100644
> --- a/drivers/net/dsa/sja1105/sja1105_spi.c
> +++ b/drivers/net/dsa/sja1105/sja1105_spi.c
> @@ -409,7 +409,8 @@ int sja1105_static_config_upload(struct sja1105_private *priv)
> rc = static_config_buf_prepare_for_upload(priv, config_buf, buf_len);
> if (rc < 0) {
> dev_err(dev, "Invalid config, cannot upload\n");
> - return -EINVAL;
> + rc = -EINVAL;
> + goto out;
> }
> /* Prevent PHY jabbering during switch reset by inhibiting
> * Tx on all ports and waiting for current packet to drain.
> @@ -418,7 +419,8 @@ int sja1105_static_config_upload(struct sja1105_private *priv)
> rc = sja1105_inhibit_tx(priv, port_bitmap, true);
> if (rc < 0) {
> dev_err(dev, "Failed to inhibit Tx on ports\n");
> - return -ENXIO;
> + rc = -ENXIO;
> + goto out;
> }
> /* Wait for an eventual egress packet to finish transmission
> * (reach IFG). It is guaranteed that a second one will not
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v3] net: dsa: sja1105: prevent leaking memory
2019-09-18 20:34 ` [PATCH v3] " Navid Emamdoost
2019-09-18 20:40 ` Vladimir Oltean
@ 2019-09-19 8:13 ` David Miller
1 sibling, 0 replies; 9+ messages in thread
From: David Miller @ 2019-09-19 8:13 UTC (permalink / raw)
To: navid.emamdoost
Cc: olteanv, emamd001, smccaman, kjlu, andrew, vivien.didelot,
f.fainelli, linux-kernel, netdev
From: Navid Emamdoost <navid.emamdoost@gmail.com>
Date: Wed, 18 Sep 2019 15:34:06 -0500
> Fixes: 8aa9ebccae87 ("net: dsa: Introduce driver for NXP SJA1105 5-port
> L2 switch")
>
> Fixes: 1a4c69406cc1 ("net: dsa: sja1105: Prevent PHY jabbering during
> switch reset")
Please:
1) Do not break Fixes: tags into multiples lines, that way the string
is easily greppable.
2) Do not separate the Fixes: from other tags with newlines. It is
just another tag like Signed-off-by: and Acked-by:
Thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] net: dsa: sja1105: prevent leaking memory
2019-09-18 20:00 ` Vladimir Oltean
2019-09-18 20:34 ` [PATCH v3] " Navid Emamdoost
@ 2019-09-19 8:10 ` David Miller
2019-09-19 8:20 ` Vladimir Oltean
1 sibling, 1 reply; 9+ messages in thread
From: David Miller @ 2019-09-19 8:10 UTC (permalink / raw)
To: olteanv
Cc: navid.emamdoost, andrew, emamd001, smccaman, kjlu,
vivien.didelot, f.fainelli, linux-kernel, netdev
From: Vladimir Oltean <olteanv@gmail.com>
Date: Wed, 18 Sep 2019 23:00:20 +0300
> Hi Navid,
>
> Thanks for the patch.
>
> On 9/18/19 9:04 PM, Navid Emamdoost wrote:
>> In sja1105_static_config_upload, in two cases memory is leaked: when
>> static_config_buf_prepare_for_upload fails and when sja1105_inhibit_tx
>> fails. In both cases config_buf should be released.
>> Fixes: 8aa9ebccae876 (avoid leaking config_buf)
>> Fixes: 1a4c69406cc1c (avoid leaking config_buf)
>>
>
> You're not supposed to add a short description of the patch here, but
> rather the commit message of the patch you're fixing.
> Add this to your ~/.gitconfig:
>
> [pretty]
> fixes = Fixes: %h (\"%s\")
>
> And then run:
> git show --pretty=fixes 8aa9ebccae87621d997707e4f25e53fddd7e30e4
>
> Fixes: 8aa9ebccae87 ("net: dsa: Introduce driver for NXP SJA1105
> 5-port L2 switch")
>
> git show --pretty=fixes 1a4c69406cc1c3c42bb7391c8eb544e93fe9b320
>
> Fixes: 1a4c69406cc1 ("net: dsa: sja1105: Prevent PHY jabbering during
> switch reset")
However the Fixes: line should not be broken up like this with newlines.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] net: dsa: sja1105: prevent leaking memory
2019-09-19 8:10 ` [PATCH v2] " David Miller
@ 2019-09-19 8:20 ` Vladimir Oltean
0 siblings, 0 replies; 9+ messages in thread
From: Vladimir Oltean @ 2019-09-19 8:20 UTC (permalink / raw)
To: David Miller
Cc: Navid Emamdoost, Andrew Lunn, Navid Emamdoost, Stephen McCamant,
kjlu, Vivien Didelot, Florian Fainelli, lkml, netdev
On Thu, 19 Sep 2019 at 11:11, David Miller <davem@davemloft.net> wrote:
>
> From: Vladimir Oltean <olteanv@gmail.com>
> Date: Wed, 18 Sep 2019 23:00:20 +0300
>
> > Hi Navid,
> >
> > Thanks for the patch.
> >
> > On 9/18/19 9:04 PM, Navid Emamdoost wrote:
> >> In sja1105_static_config_upload, in two cases memory is leaked: when
> >> static_config_buf_prepare_for_upload fails and when sja1105_inhibit_tx
> >> fails. In both cases config_buf should be released.
> >> Fixes: 8aa9ebccae876 (avoid leaking config_buf)
> >> Fixes: 1a4c69406cc1c (avoid leaking config_buf)
> >>
> >
> > You're not supposed to add a short description of the patch here, but
> > rather the commit message of the patch you're fixing.
> > Add this to your ~/.gitconfig:
> >
> > [pretty]
> > fixes = Fixes: %h (\"%s\")
> >
> > And then run:
> > git show --pretty=fixes 8aa9ebccae87621d997707e4f25e53fddd7e30e4
> >
> > Fixes: 8aa9ebccae87 ("net: dsa: Introduce driver for NXP SJA1105
> > 5-port L2 switch")
> >
> > git show --pretty=fixes 1a4c69406cc1c3c42bb7391c8eb544e93fe9b320
> >
> > Fixes: 1a4c69406cc1 ("net: dsa: sja1105: Prevent PHY jabbering during
> > switch reset")
>
> However the Fixes: line should not be broken up like this with newlines.
Sorry, my mail client did that automatically.
-Vladimir
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2019-09-19 8:20 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18 17:10 [PATCH] net: dsa: sja1105: prevent leaking memory Navid Emamdoost
2019-09-18 17:21 ` Andrew Lunn
2019-09-18 18:04 ` [PATCH v2] " Navid Emamdoost
2019-09-18 20:00 ` Vladimir Oltean
2019-09-18 20:34 ` [PATCH v3] " Navid Emamdoost
2019-09-18 20:40 ` Vladimir Oltean
2019-09-19 8:13 ` David Miller
2019-09-19 8:10 ` [PATCH v2] " David Miller
2019-09-19 8:20 ` Vladimir Oltean
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).