]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: fix memory leak
authorPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 25 Sep 2019 06:51:06 +0000 (08:51 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Wed, 25 Sep 2019 06:51:06 +0000 (08:51 +0200)
the if_lookup_by_name_per_ns keeps a lock on the node where the
searched ifp is stored. Then this node can not be freed even if
the ifp is removed from the node. Just add the missing unlock
(as for the if_lookup_by_index_per_ns lookup function)

Fixes: b8af3fbbafc8 ("zebra: fix detection of interface renames")
Signed-off-by: Thibaut Collet <thibaut.collet@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
zebra/interface.c

index 6486c01430c39bc02c1c8e8538053903c4064558..368eecc2cfac17f5dd57a7bb9a9f380802d469f1 100644 (file)
@@ -261,8 +261,10 @@ struct interface *if_lookup_by_name_per_ns(struct zebra_ns *ns,
 
        for (rn = route_top(ns->if_table); rn; rn = route_next(rn)) {
                ifp = (struct interface *)rn->info;
-               if (ifp && strcmp(ifp->name, ifname) == 0)
+               if (ifp && strcmp(ifp->name, ifname) == 0) {
+                       route_unlock_node(rn);
                        return (ifp);
+               }
        }
 
        return NULL;