[netifd PATCH] bridge: always insert new member if allocated on hotplug add
Christian Marangi
ansuelsmth at gmail.com
Sat Jun 24 05:34:12 PDT 2023
Fix Coverity Defect 1532481 reporting a Resource leak when
!bm->node.avl.key is false in bridge_hotplug_add.
While this situation is almost impossible, code can be refactored to
mute the defect and make it clear that we insert only when a new member
is allocated.
Fixes: edf3aced9f9a ("bridge: add support for adding vlan ranges via hotplug")
Signed-off-by: Christian Marangi <ansuelsmth at gmail.com>
---
bridge.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/bridge.c b/bridge.c
index 471c651..202b69b 100644
--- a/bridge.c
+++ b/bridge.c
@@ -930,12 +930,15 @@ bridge_hotplug_add(struct device *dev, struct device *member, struct blob_attr *
{
struct bridge_state *bst = container_of(dev, struct bridge_state, dev);
struct bridge_member *bm;
+ bool to_insert = false;
bm = vlist_find(&bst->members, member->ifname, bm, node);
- if (!bm)
+ if (!bm) {
+ to_insert = true;
bm = bridge_alloc_member(bst, member->ifname, member, true);
+ }
bridge_hotplug_set_member_vlans(bst, vlan, member->ifname, bm, true);
- if (!bm->node.avl.key)
+ if (to_insert)
bridge_insert_member(bm, member->ifname);
return 0;
--
2.40.1
More information about the openwrt-devel
mailing list