[ovs-dev] [PATCH] dpif-netdev: Fix leaked port and port->rxq in error path

Ben Pfaff blp at nicira.com
Tue Aug 26 18:28:10 UTC 2014


On Tue, Aug 26, 2014 at 06:36:08PM +0200, Thomas Graf wrote:
> Signed-off-by: Thomas Graf <tgraf at noironetworks.com>
> ---
>  lib/dpif-netdev.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index 7401293..c7a1242 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -669,6 +669,8 @@ do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
>              VLOG_ERR("%s: cannot receive packets on this network device (%s)",
>                       devname, ovs_strerror(errno));
>              netdev_close(netdev);
> +            free(port->rxq);
> +            free(port);
>              return error;
>          }
>      }

This still missed port->type so I redid it as follows and will push in
a minute after testing.

--8<--------------------------cut here-------------------------->8--

From: Thomas Graf <tgraf at noironetworks.com>
Date: Tue, 26 Aug 2014 18:36:08 +0200
Subject: [PATCH] dpif-netdev: Fix leaked port, port->rxq, port->type in error
 path

Signed-off-by: Thomas Graf <tgraf at noironetworks.com>
[blp at nicira.com added free of port->type]
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 lib/dpif-netdev.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 7401293..9e01931 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -669,6 +669,9 @@ do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
             VLOG_ERR("%s: cannot receive packets on this network device (%s)",
                      devname, ovs_strerror(errno));
             netdev_close(netdev);
+            free(port->type);
+            free(port->rxq);
+            free(port);
             return error;
         }
     }
@@ -679,6 +682,7 @@ do_add_port(struct dp_netdev *dp, const char *devname, const char *type,
             netdev_rxq_close(port->rxq[i]);
         }
         netdev_close(netdev);
+        free(port->type);
         free(port->rxq);
         free(port);
         return error;
-- 
1.7.10.4




More information about the dev mailing list