Instead of freeing in the error path, move the allocation after it. Found by inspection.
Signed-off-by: William Tu <[email protected]> --- lib/netdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/netdev.c b/lib/netdev.c index b4e570bafd08..e47bfe1c831d 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -2214,19 +2214,18 @@ netdev_ports_insert(struct netdev *netdev, const struct dpif_class *dpif_class, return ENODEV; } - data = xzalloc(sizeof *data); - ifidx = xzalloc(sizeof *ifidx); - ovs_mutex_lock(&netdev_hmap_mutex); if (netdev_ports_lookup(dpif_port->port_no, dpif_class)) { ovs_mutex_unlock(&netdev_hmap_mutex); return EEXIST; } + data = xzalloc(sizeof *data); data->netdev = netdev_ref(netdev); data->dpif_class = dpif_class; dpif_port_clone(&data->dpif_port, dpif_port); + ifidx = xzalloc(sizeof *ifidx); ifidx->ifindex = ifindex; ifidx->port = dpif_port->port_no; -- 2.7.4 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
