diff mbox series

[net-next] net: dsa: qca8k: fix missing unlock on error in qca8k_vlan_(add|del)

Message ID 20210518112413.622913-1-weiyongjun1@huawei.com (mailing list archive)
State Accepted
Commit 0d56e5c191b197e1d30a0a4c92628836dafced0f
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: dsa: qca8k: fix missing unlock on error in qca8k_vlan_(add|del) | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 40 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Wei Yongjun May 18, 2021, 11:24 a.m. UTC
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>
---
 drivers/net/dsa/qca8k.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

Comments

Vladimir Oltean May 18, 2021, 4:27 p.m. UTC | #1
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);
>  	}
>  
>
patchwork-bot+netdevbpf@kernel.org May 18, 2021, 8:50 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Tue, 18 May 2021 11:24:13 +0000 you 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>
> 
> [...]

Here is the summary with links:
  - [net-next] net: dsa: qca8k: fix missing unlock on error in qca8k_vlan_(add|del)
    https://git.kernel.org/netdev/net-next/c/0d56e5c191b1

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

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;
+	}
 	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);
 	}