From 280532ae0143093fdd8e92eac0c0de0aad33c262 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 4 Jan 2013 13:48:19 -0800 Subject: [PATCH] rconn: Avoid memory leak in rconn_send_with_limit() on queue overflow. Bug #14357. Reported-by: Luca Giraudo Signed-off-by: Ben Pfaff --- lib/rconn.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/rconn.c b/lib/rconn.c index ddf578c18..0b55ed089 100644 --- a/lib/rconn.c +++ b/lib/rconn.c @@ -632,14 +632,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 -- 2.20.1