diff options
author | Colin Ian King <colin.king@canonical.com> | 2016-08-11 18:17:22 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-08-13 14:56:17 -0700 |
commit | b4c0e0c61f81dedc82dda35c287ea149ff98b434 (patch) | |
tree | ec7aea76bd12aa927205b592f846f782cc8904d2 /net/ipv6/calipso.c | |
parent | 747ea55e4f78fd980350c39570a986b8c1c3e4aa (diff) | |
download | linux-stable-b4c0e0c61f81dedc82dda35c287ea149ff98b434.tar.gz linux-stable-b4c0e0c61f81dedc82dda35c287ea149ff98b434.tar.bz2 linux-stable-b4c0e0c61f81dedc82dda35c287ea149ff98b434.zip |
calipso: fix resource leak on calipso_genopt failure
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/calipso.c')
-rw-r--r-- | net/ipv6/calipso.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c index c53b92c617c5..37ac9de713c6 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 */ |