[ovs-dev] [PATCHv2] netdev: Free ifidx mapping in netdev_ports_remove().
Joe Stringer
joe at ovn.org
Fri Aug 11 16:49:22 UTC 2017
On 9 August 2017 at 17:18, Joe Stringer <joe at ovn.org> wrote:
> Previously, netdev_ports_insert() would allocate and insert an
> ifindex->odp_port mapping, but netdev_ports_remove() would never remove
> the mapping or free the mapping structure. This patch fixes these up.
>
> Fixes: 32b77c316d9982("dpif: Save added ports in a port map.")
> Reported-by: Andy Zhou <azhou at ovn.org>
> Signed-off-by: Joe Stringer <joe at ovn.org>
> Acked-by: Andy Zhou <azhou at ovn.org>
> ---
Andy gave me an offline review of this, so I applied this incremental
and pushed the patch to master and branch-2.8:
diff --git a/lib/netdev.c b/lib/netdev.c
index 3cf9117b3683..b4e570bafd08 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -2272,12 +2272,13 @@ netdev_ports_remove(odp_port_t port_no, const
struct dpif_class *dpif_class)
struct ifindex_to_port_data *ifidx = NULL;
HMAP_FOR_EACH_WITH_HASH (ifidx, node, ifindex, &ifindex_to_port) {
- if (ifidx && ifidx->port == port_no) {
+ if (ifidx->port == port_no) {
hmap_remove(&ifindex_to_port, &ifidx->node);
+ free(ifidx);
break;
}
}
- free(ifidx);
+ ovs_assert(ifidx);
} else {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
More information about the dev
mailing list