summaryrefslogtreecommitdiff
path: root/net/key
diff options
context:
space:
mode:
authorSteffen Klassert <steffen.klassert@secunet.com>2018-01-10 11:33:26 +0300
committerSteffen Klassert <steffen.klassert@secunet.com>2018-01-10 11:45:11 +0300
commit1e532d2b49645e7cb76d5af6cb5bc4ec93d861ae (patch)
tree511cdfd2168fbdd9c5ab32573fca8c4e9299fc45 /net/key
parent374d1b5a81f7f9cc5e7f095ac3d5aff3f6600376 (diff)
downloadlinux-1e532d2b49645e7cb76d5af6cb5bc4ec93d861ae.tar.xz
af_key: Fix memory leak in key_notify_policy.
We leak the allocated out_skb in case pfkey_xfrm_policy2msg() fails. Fix this by freeing it on error. Reported-by: Dmitry Vyukov <dvyukov@google.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/key')
-rw-r--r--net/key/af_key.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c
index d40861a048fe..7e2e7188e7f4 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -2202,8 +2202,10 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, const struct km_ev
return PTR_ERR(out_skb);
err = pfkey_xfrm_policy2msg(out_skb, xp, dir);
- if (err < 0)
+ if (err < 0) {
+ kfree_skb(out_skb);
return err;
+ }
out_hdr = (struct sadb_msg *) out_skb->data;
out_hdr->sadb_msg_version = PF_KEY_V2;