netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] af_key: Fix memory leak in key_notify_policy.
@ 2019-06-14  8:26 Young Xiao
  2019-06-14  8:53 ` Steffen Klassert
  0 siblings, 1 reply; 6+ messages in thread
From: Young Xiao @ 2019-06-14  8:26 UTC (permalink / raw)
  To: steffen.klassert, herbert, davem, netdev, linux-kernel; +Cc: Young Xiao

We leak the allocated out_skb in case pfkey_xfrm_policy2msg() fails.
Fix this by freeing it on error.

Signed-off-by: Young Xiao <92siuyang@gmail.com>
---
 net/key/af_key.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/key/af_key.c b/net/key/af_key.c
index 4af1e1d..ec414f6 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -2443,6 +2443,7 @@ static int key_pol_get_resp(struct sock *sk, struct xfrm_policy *xp, const struc
 	}
 	err = pfkey_xfrm_policy2msg(out_skb, xp, dir);
 	if (err < 0)
+		kfree_skb(out_skb);
 		goto out;
 
 	out_hdr = (struct sadb_msg *) out_skb->data;
@@ -2695,6 +2696,7 @@ static int dump_sp(struct xfrm_policy *xp, int dir, int count, void *ptr)
 
 	err = pfkey_xfrm_policy2msg(out_skb, xp, dir);
 	if (err < 0)
+		kfree_skb(out_skb);
 		return err;
 
 	out_hdr = (struct sadb_msg *) out_skb->data;
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-06-14 10:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-14  8:26 [PATCH] af_key: Fix memory leak in key_notify_policy Young Xiao
2019-06-14  8:53 ` Steffen Klassert
2019-06-14  9:59   ` Jeremy Sowden
2019-06-14 10:13     ` Jeremy Sowden
2019-06-14 10:17       ` Steffen Klassert
2019-06-14 10:31         ` Jeremy Sowden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).