diff mbox

[ovs-dev,PATCHv2] netdev: Free ifidx mapping in netdev_ports_remove().

Message ID CAPWQB7HvG1HPVwU16-Rzc7WL329sD0FOijXPxFXEsvsmEdkO-Q@mail.gmail.com
State Not Applicable
Headers show

Commit Message

Joe Stringer Aug. 11, 2017, 4:49 p.m. UTC
On 9 August 2017 at 17:18, Joe Stringer <joe@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@ovn.org>
> Signed-off-by: Joe Stringer <joe@ovn.org>
> Acked-by: Andy Zhou <azhou@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 mbox

Patch

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);