netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Navid Emamdoost <navid.emamdoost@gmail.com>
Cc: Navid Emamdoost <emamd001@umn.edu>,
	Stephen McCamant <smccaman@umn.edu>,
	kjlu@umn.edu, Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	lkml <linux-kernel@vger.kernel.org>,
	netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH v3] net: dsa: sja1105: prevent leaking memory
Date: Wed, 18 Sep 2019 23:40:59 +0300	[thread overview]
Message-ID: <CA+h21ho_pibJNnYkyYrJGACmwU16Qk3ZZ=BJEqQjBbK3CW+Gog@mail.gmail.com> (raw)
In-Reply-To: <20190918203407.23826-1-navid.emamdoost@gmail.com>

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
>

  reply	other threads:[~2019-09-18 20:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2019-09-19  8:13         ` David Miller
2019-09-19  8:10       ` [PATCH v2] " David Miller
2019-09-19  8:20         ` Vladimir Oltean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+h21ho_pibJNnYkyYrJGACmwU16Qk3ZZ=BJEqQjBbK3CW+Gog@mail.gmail.com' \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=emamd001@umn.edu \
    --cc=f.fainelli@gmail.com \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=navid.emamdoost@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=smccaman@umn.edu \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).