ofproto-dpif: Fix memory leak in type_run().
authorBen Pfaff <blp@nicira.com>
Tue, 18 Dec 2012 21:17:00 +0000 (13:17 -0800)
committerBen Pfaff <blp@nicira.com>
Tue, 18 Dec 2012 23:52:21 +0000 (15:52 -0800)
The dpif_port_destroy() call was in the dpif_port_query_by_name() error
path, when there's nothing to destroy, rather than in the "success" path,
where there is data to destroy.

Signed-off-by: Ben Pfaff <blp@nicira.com>
ofproto/ofproto-dpif.c

index 95fd54e..b78d6cf 100644 (file)
@@ -850,12 +850,12 @@ type_run(const char *type)
                 sset_add(&ofproto->port_poll_set, devname);
                 ofproto->port_poll_errno = 0;
             }
-            dpif_port_destroy(&port);
         } else if (!ofproto) {
             /* The port was added, but we don't know with which
              * ofproto we should associate it.  Delete it. */
             dpif_port_del(backer->dpif, port.port_no);
         }
+        dpif_port_destroy(&port);
 
         free(devname);
     }