public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Wei Yongjun <weiyongjun1@huawei.com>
Cc: Ansuel Smith <ansuelsmth@gmail.com>, Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	netdev@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Hulk Robot <hulkci@huawei.com>
Subject: Re: [PATCH net-next] net: dsa: qca8k: fix missing unlock on error in qca8k_vlan_(add|del)
Date: Tue, 18 May 2021 19:27:27 +0300	[thread overview]
Message-ID: <20210518162727.74gynfdtrzuyneul@skbuf> (raw)
In-Reply-To: <20210518112413.622913-1-weiyongjun1@huawei.com>

Hi Yongjun,

On Tue, May 18, 2021 at 11:24:13AM +0000, Wei Yongjun wrote:
> Add the missing unlock before return from function qca8k_vlan_add()
> and qca8k_vlan_del() in the error handling case.
> 
> Fixes: 028f5f8ef44f ("net: dsa: qca8k: handle error with qca8k_read operation")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---

Reviewed-by: Vladimir Oltean <olteanv@gmail.com>

>  drivers/net/dsa/qca8k.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/dsa/qca8k.c b/drivers/net/dsa/qca8k.c
> index 4753228f02b3..1f1b7c4dda13 100644
> --- a/drivers/net/dsa/qca8k.c
> +++ b/drivers/net/dsa/qca8k.c
> @@ -506,8 +506,10 @@ qca8k_vlan_add(struct qca8k_priv *priv, u8 port, u16 vid, bool untagged)
>  		goto out;
>  
>  	reg = qca8k_read(priv, QCA8K_REG_VTU_FUNC0);
> -	if (reg < 0)
> -		return reg;
> +	if (reg < 0) {
> +		ret = reg;
> +		goto out;
> +	}

This is fuzzy and has been pointed out before by Russell. reg is unsigned, ret is signed.
An extra patch would be good to use an "int" everywhere.

>  	reg |= QCA8K_VTU_FUNC0_VALID | QCA8K_VTU_FUNC0_IVL_EN;
>  	reg &= ~(QCA8K_VTU_FUNC0_EG_MODE_MASK << QCA8K_VTU_FUNC0_EG_MODE_S(port));
>  	if (untagged)
> @@ -519,7 +521,7 @@ qca8k_vlan_add(struct qca8k_priv *priv, u8 port, u16 vid, bool untagged)
>  
>  	ret = qca8k_write(priv, QCA8K_REG_VTU_FUNC0, reg);
>  	if (ret)
> -		return ret;
> +		goto out;
>  	ret = qca8k_vlan_access(priv, QCA8K_VLAN_LOAD, vid);
>  
>  out:
> @@ -541,8 +543,10 @@ qca8k_vlan_del(struct qca8k_priv *priv, u8 port, u16 vid)
>  		goto out;
>  
>  	reg = qca8k_read(priv, QCA8K_REG_VTU_FUNC0);
> -	if (reg < 0)
> -		return reg;
> +	if (reg < 0) {
> +		ret = reg;
> +		goto out;
> +	}
>  	reg &= ~(3 << QCA8K_VTU_FUNC0_EG_MODE_S(port));
>  	reg |= QCA8K_VTU_FUNC0_EG_MODE_NOT <<
>  			QCA8K_VTU_FUNC0_EG_MODE_S(port);
> @@ -564,7 +568,7 @@ qca8k_vlan_del(struct qca8k_priv *priv, u8 port, u16 vid)
>  	} else {
>  		ret = qca8k_write(priv, QCA8K_REG_VTU_FUNC0, reg);
>  		if (ret)
> -			return ret;
> +			goto out;
>  		ret = qca8k_vlan_access(priv, QCA8K_VLAN_LOAD, vid);
>  	}
>  
> 


  reply	other threads:[~2021-05-18 16:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 11:24 [PATCH net-next] net: dsa: qca8k: fix missing unlock on error in qca8k_vlan_(add|del) Wei Yongjun
2021-05-18 16:27 ` Vladimir Oltean [this message]
2021-05-18 20:50 ` patchwork-bot+netdevbpf

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=20210518162727.74gynfdtrzuyneul@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hulkci@huawei.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    --cc=weiyongjun1@huawei.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