a68e3b1821c9446ddcf59264449c624b85bf6647
[openwrt/staging/neocturne.git] /
1 From 0d56e5c191b197e1d30a0a4c92628836dafced0f Mon Sep 17 00:00:00 2001
2 From: Wei Yongjun <weiyongjun1@huawei.com>
3 Date: Tue, 18 May 2021 11:24:13 +0000
4 Subject: [PATCH] net: dsa: qca8k: fix missing unlock on error in
5 qca8k_vlan_(add|del)
6
7 Add the missing unlock before return from function qca8k_vlan_add()
8 and qca8k_vlan_del() in the error handling case.
9
10 Fixes: 028f5f8ef44f ("net: dsa: qca8k: handle error with qca8k_read operation")
11 Reported-by: Hulk Robot <hulkci@huawei.com>
12 Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
13 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
15 ---
16 drivers/net/dsa/qca8k.c | 16 ++++++++++------
17 1 file changed, 10 insertions(+), 6 deletions(-)
18
19 --- a/drivers/net/dsa/qca8k.c
20 +++ b/drivers/net/dsa/qca8k.c
21 @@ -506,8 +506,10 @@ qca8k_vlan_add(struct qca8k_priv *priv,
22 goto out;
23
24 reg = qca8k_read(priv, QCA8K_REG_VTU_FUNC0);
25 - if (reg < 0)
26 - return reg;
27 + if (reg < 0) {
28 + ret = reg;
29 + goto out;
30 + }
31 reg |= QCA8K_VTU_FUNC0_VALID | QCA8K_VTU_FUNC0_IVL_EN;
32 reg &= ~(QCA8K_VTU_FUNC0_EG_MODE_MASK << QCA8K_VTU_FUNC0_EG_MODE_S(port));
33 if (untagged)
34 @@ -519,7 +521,7 @@ qca8k_vlan_add(struct qca8k_priv *priv,
35
36 ret = qca8k_write(priv, QCA8K_REG_VTU_FUNC0, reg);
37 if (ret)
38 - return ret;
39 + goto out;
40 ret = qca8k_vlan_access(priv, QCA8K_VLAN_LOAD, vid);
41
42 out:
43 @@ -541,8 +543,10 @@ qca8k_vlan_del(struct qca8k_priv *priv,
44 goto out;
45
46 reg = qca8k_read(priv, QCA8K_REG_VTU_FUNC0);
47 - if (reg < 0)
48 - return reg;
49 + if (reg < 0) {
50 + ret = reg;
51 + goto out;
52 + }
53 reg &= ~(3 << QCA8K_VTU_FUNC0_EG_MODE_S(port));
54 reg |= QCA8K_VTU_FUNC0_EG_MODE_NOT <<
55 QCA8K_VTU_FUNC0_EG_MODE_S(port);
56 @@ -564,7 +568,7 @@ qca8k_vlan_del(struct qca8k_priv *priv,
57 } else {
58 ret = qca8k_write(priv, QCA8K_REG_VTU_FUNC0, reg);
59 if (ret)
60 - return ret;
61 + goto out;
62 ret = qca8k_vlan_access(priv, QCA8K_VLAN_LOAD, vid);
63 }
64