Commit 4c0833bc authored by Tobias Klauser's avatar Tobias Klauser Committed by David S. Miller

bridge: Fix return values of br_multicast_add_group/br_multicast_new_group

If br_multicast_new_group returns NULL, we would return 0 (no error) to
the caller of br_multicast_add_group, which is not what we want. Instead
br_multicast_new_group should return ERR_PTR(-ENOMEM) in this case.
Also propagate the error number returned by br_mdb_rehash properly.
Signed-off-by: default avatarTobias Klauser <tklauser@distanz.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent eaa7dcde
...@@ -654,11 +654,13 @@ static struct net_bridge_mdb_entry *br_multicast_new_group( ...@@ -654,11 +654,13 @@ static struct net_bridge_mdb_entry *br_multicast_new_group(
struct net_bridge_mdb_htable *mdb; struct net_bridge_mdb_htable *mdb;
struct net_bridge_mdb_entry *mp; struct net_bridge_mdb_entry *mp;
int hash; int hash;
int err;
mdb = rcu_dereference_protected(br->mdb, 1); mdb = rcu_dereference_protected(br->mdb, 1);
if (!mdb) { if (!mdb) {
if (br_mdb_rehash(&br->mdb, BR_HASH_SIZE, 0)) err = br_mdb_rehash(&br->mdb, BR_HASH_SIZE, 0);
return NULL; if (err)
return ERR_PTR(err);
goto rehash; goto rehash;
} }
...@@ -680,7 +682,7 @@ static struct net_bridge_mdb_entry *br_multicast_new_group( ...@@ -680,7 +682,7 @@ static struct net_bridge_mdb_entry *br_multicast_new_group(
mp = kzalloc(sizeof(*mp), GFP_ATOMIC); mp = kzalloc(sizeof(*mp), GFP_ATOMIC);
if (unlikely(!mp)) if (unlikely(!mp))
goto out; return ERR_PTR(-ENOMEM);
mp->br = br; mp->br = br;
mp->addr = *group; mp->addr = *group;
...@@ -713,7 +715,7 @@ static int br_multicast_add_group(struct net_bridge *br, ...@@ -713,7 +715,7 @@ static int br_multicast_add_group(struct net_bridge *br,
mp = br_multicast_new_group(br, port, group); mp = br_multicast_new_group(br, port, group);
err = PTR_ERR(mp); err = PTR_ERR(mp);
if (unlikely(IS_ERR(mp) || !mp)) if (IS_ERR(mp))
goto err; goto err;
if (!port) { if (!port) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment