[ovs-dev] [PATCH v3 08/17] dpif-netdev: Fix memory leak in tunnel header push action.

Pravin B Shelar pshelar at ovn.org
Tue May 10 17:30:51 UTC 2016


in case of error from netdev_push_header() batch of packets was not
freed. Following patch fixes this issue.

Signed-off-by: Pravin B Shelar <pshelar at ovn.org>
---
 lib/dpif-netdev.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index f0d5fca..9ff413f 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -3685,16 +3685,22 @@ push_tnl_action(const struct dp_netdev *dp,
 {
     struct dp_netdev_port *tun_port;
     const struct ovs_action_push_tnl *data;
+    int err;
 
     data = nl_attr_get(attr);
 
     tun_port = dp_netdev_lookup_port(dp, u32_to_odp(data->tnl_port));
     if (!tun_port) {
-        return -EINVAL;
+        err = -EINVAL;
+        goto error;
     }
-    netdev_push_header(tun_port->netdev, batch, data);
-
-    return 0;
+    err = netdev_push_header(tun_port->netdev, batch, data);
+    if (!err) {
+        return 0;
+    }
+error:
+    dp_packet_delete_batch(batch, true);
+    return err;
 }
 
 static void
@@ -3737,8 +3743,6 @@ dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
                 (*depth)++;
                 dp_netdev_recirculate(pmd, packets_);
                 (*depth)--;
-            } else {
-                dp_packet_delete_batch(&tnl_pkt, !may_steal);
             }
             return;
         }
-- 
2.5.5




More information about the dev mailing list