From: Ben Pfaff Date: Thu, 1 Aug 2013 21:07:35 +0000 (-0700) Subject: dpif-linux: Fix theoretical memory leak on error path. X-Git-Tag: sliver-openvswitch-2.0.90-1~33^2~45 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=59e0c910d043a8f91abc429925f53d34912dac09;p=sliver-openvswitch.git dpif-linux: Fix theoretical memory leak on error path. If a notification is bigger than 4 kB (I doubt it one would be), then the lack of ofpbuf_uninit() would cause a memory leak. Signed-off-by: Ben Pfaff --- diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c index 27c622aa2..1b97410e7 100644 --- a/lib/dpif-linux.c +++ b/lib/dpif-linux.c @@ -799,19 +799,21 @@ dpif_linux_port_poll(const struct dpif *dpif_, char **devnamep) VLOG_DBG("port_changed: dpif:%s vport:%s cmd:%"PRIu8, dpif->dpif.full_name, vport.name, vport.cmd); *devnamep = xstrdup(vport.name); + ofpbuf_uninit(&buf); return 0; - } else { - continue; } } - } else if (error == EAGAIN) { - return EAGAIN; + } else if (error != EAGAIN) { + VLOG_WARN_RL(&rl, "error reading or parsing netlink (%s)", + ovs_strerror(error)); + nl_sock_drain(dpif->port_notifier); + error = ENOBUFS; } - VLOG_WARN_RL(&rl, "error reading or parsing netlink (%s)", - ovs_strerror(error)); - nl_sock_drain(dpif->port_notifier); - return ENOBUFS; + ofpbuf_uninit(&buf); + if (error) { + return error; + } } }