From: Ben Pfaff Date: Fri, 4 Jan 2013 21:48:19 +0000 (-0800) Subject: rconn: Avoid memory leak in rconn_send_with_limit() on queue overflow. X-Git-Tag: sliver-openvswitch-1.9.90-3~10^2~36 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=b8dddecfcc418ac4dcf01f6c57d976895e549c49;p=sliver-openvswitch.git rconn: Avoid memory leak in rconn_send_with_limit() on queue overflow. Bug #14357. Reported-by: Luca Giraudo Signed-off-by: Ben Pfaff --- diff --git a/lib/rconn.c b/lib/rconn.c index 7a2bcf5e4..002f3676b 100644 --- a/lib/rconn.c +++ b/lib/rconn.c @@ -649,14 +649,13 @@ int rconn_send_with_limit(struct rconn *rc, struct ofpbuf *b, struct rconn_packet_counter *counter, int queue_limit) { - int retval; - retval = (counter->n_packets >= queue_limit - ? EAGAIN - : rconn_send(rc, b, counter)); - if (retval) { + if (counter->n_packets < queue_limit) { + return rconn_send(rc, b, counter); + } else { COVERAGE_INC(rconn_overflow); + ofpbuf_delete(b); + return EAGAIN; } - return retval; } /* Returns the total number of packets successfully sent on the underlying