From: Justin Pettit Date: Wed, 16 Jan 2013 23:53:14 +0000 (-0800) Subject: dpif-linux: Fix segfault when a port already exists. X-Git-Tag: sliver-openvswitch-1.9.90-3~8^2~20 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=sidebyside;h=2510ba7cfde15fdacea42e920c61d7be131ba0cd;p=sliver-openvswitch.git dpif-linux: Fix segfault when a port already exists. Commit 78a2d59c (dpif-linux.c: Let the kernel pick a port number if one not requested.) changed the logic for port assignment, but didn't properly handle some error conditions. An attempt to add a tunnel port that already exists would lead to a segfault. This commit fixes the logic to stop processing and return an error. Reported-by: Gurucharan Shetty Signed-off-by: Justin Pettit --- diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c index cde116727..4425f6f92 100644 --- a/lib/dpif-linux.c +++ b/lib/dpif-linux.c @@ -474,9 +474,11 @@ dpif_linux_port_add(struct dpif *dpif_, struct netdev *netdev, *port_nop = reply.port_no; VLOG_DBG("%s: assigning port %"PRIu32" to netlink pid %"PRIu32, dpif_name(dpif_), reply.port_no, upcall_pid); - } else if (error == EBUSY && *port_nop != UINT32_MAX) { - VLOG_INFO("%s: requested port %"PRIu32" is in use", - dpif_name(dpif_), *port_nop); + } else { + if (error == EBUSY && *port_nop != UINT32_MAX) { + VLOG_INFO("%s: requested port %"PRIu32" is in use", + dpif_name(dpif_), *port_nop); + } nl_sock_destroy(sock); ofpbuf_delete(buf); return error;