* [PATCH] calipso: fix resource leak on calipso_genopt failure
@ 2016-08-11 17:17 Colin King
2016-08-13 21:56 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2016-08-11 17:17 UTC (permalink / raw)
To: David S . Miller, Alexey Kuznetsov, James Morris,
Hideaki YOSHIFUJI, Patrick McHardy, netdev
Cc: linux-kernel
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] calipso: fix resource leak on calipso_genopt failure
2016-08-11 17:17 [PATCH] calipso: fix resource leak on calipso_genopt failure Colin King
@ 2016-08-13 21:56 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-08-13 21:56 UTC (permalink / raw)
To: colin.king; +Cc: kuznet, jmorris, yoshfuji, kaber, netdev, linux-kernel
From: Colin King <colin.king@canonical.com>
Date: Thu, 11 Aug 2016 18:17:22 +0100
> 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>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-08-14 9:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-11 17:17 [PATCH] calipso: fix resource leak on calipso_genopt failure Colin King
2016-08-13 21:56 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.