Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1460707

[PATCH] calipso: fix resource leak on calipso_genopt failure

From Colin King <colin.king@canonical.com>
Newsgroups linux.kernel
Subject [PATCH] calipso: fix resource leak on calipso_genopt failure
Date 2016-08-11 19:20 +0200
Message-ID <s51O9-6MP-5@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


From: Colin Ian King <colin.king@canonical.com>

Currently, if calipso_genopt fails then the error exit path
does not free the ipv6_opt_hdr new causing a memory leak. Fix
this by kfree'ing new on the error exit path.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 net/ipv6/calipso.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
index c53b92c..37ac9de 100644
--- a/net/ipv6/calipso.c
+++ b/net/ipv6/calipso.c
@@ -952,8 +952,10 @@ calipso_opt_insert(struct ipv6_opt_hdr *hop,
 		memcpy(new, hop, start);
 	ret_val = calipso_genopt((unsigned char *)new, start, buf_len, doi_def,
 				 secattr);
-	if (ret_val < 0)
+	if (ret_val < 0) {
+		kfree(new);
 		return ERR_PTR(ret_val);
+	}
 
 	buf_len = start + ret_val;
 	/* At this point buf_len aligns to 4n, so (buf_len & 4) pads to 8n */
-- 
2.8.1

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] calipso: fix resource leak on calipso_genopt failure Colin King <colin.king@canonical.com> - 2016-08-11 19:20 +0200
  Re: [PATCH] calipso: fix resource leak on calipso_genopt failure David Miller <davem@davemloft.net> - 2016-08-14 11:50 +0200

csiph-web