[ovs-dev] [PATCH 2/2] dpif-netdev: Fix memory leak.

Alex Wang alexw at nicira.com
Fri Feb 21 06:04:54 UTC 2014


In dpif_netdev_flow_del() and dp_netdev_port_input(), the
referenced 'netdev_flow' is not un-referenced.  This causes
the leak of the struct's memory.

This commit fixes the above issue by calling dp_netdev_flow_unref()
after using the reference.

Signed-off-by: Alex Wang <alexw at nicira.com>
---
 lib/dpif-netdev.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 9ba93dd..c4ba646 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -1295,6 +1295,7 @@ dpif_netdev_flow_del(struct dpif *dpif, const struct dpif_flow_del *del)
             ovs_mutex_unlock(&netdev_flow->mutex);
         }
         dp_netdev_remove_flow(dp, netdev_flow);
+        dp_netdev_flow_unref(netdev_flow);
     } else {
         error = ENOENT;
     }
@@ -1706,6 +1707,7 @@ dp_netdev_port_input(struct dp_netdev *dp, struct ofpbuf *packet,
         dp_netdev_execute_actions(dp, &key, packet, md,
                                   actions->actions, actions->size);
         dp_netdev_actions_unref(actions);
+        dp_netdev_flow_unref(netdev_flow);
         ovsthread_counter_inc(dp->n_hit, 1);
     } else {
         ovsthread_counter_inc(dp->n_missed, 1);
-- 
1.7.9.5




More information about the dev mailing list