summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2021-10-24 20:17:48 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-11-18 21:16:41 +0300
commit348273847a56ac4a2bcb148000b8e7ac9cde0078 (patch)
tree99bf68c66b8822c774e2d115dd374aeaee7a78e4 /net
parent69abfe39c7d6f9c2162e1f7a3b1950124144a1de (diff)
downloadlinux-348273847a56ac4a2bcb148000b8e7ac9cde0078.tar.xz
net: dsa: avoid refcount warnings when ->port_{fdb,mdb}_del returns error
[ Upstream commit 232deb3f9567ce37d99b8616a6c07c1fc0436abf ] At present, when either of ds->ops->port_fdb_del() or ds->ops->port_mdb_del() return a non-zero error code, we attempt to save the day and keep the data structure associated with that switchdev object, as the deletion procedure did not complete. However, the way in which we do this is suspicious to the checker in lib/refcount.c, who thinks it is buggy to increment a refcount that became zero, and that this is indicative of a use-after-free. Fixes: 161ca59d39e9 ("net: dsa: reference count the MDB entries at the cross-chip notifier level") Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/dsa/switch.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/dsa/switch.c b/net/dsa/switch.c
index 6466d0539af9..44558fbdc65b 100644
--- a/net/dsa/switch.c
+++ b/net/dsa/switch.c
@@ -264,7 +264,7 @@ static int dsa_switch_do_mdb_del(struct dsa_switch *ds, int port,
err = ds->ops->port_mdb_del(ds, port, mdb);
if (err) {
- refcount_inc(&a->refcount);
+ refcount_set(&a->refcount, 1);
return err;
}
@@ -329,7 +329,7 @@ static int dsa_switch_do_fdb_del(struct dsa_switch *ds, int port,
err = ds->ops->port_fdb_del(ds, port, addr, vid);
if (err) {
- refcount_inc(&a->refcount);
+ refcount_set(&a->refcount, 1);
return err;
}