From: Steffen Klassert Date: Wed, 10 Jan 2018 08:33:26 +0000 (+0100) Subject: af_key: Fix memory leak in key_notify_policy. X-Git-Tag: v4.15~60^2~26^2~1 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=1e532d2b49645e7cb76d5af6cb5bc4ec93d861ae;p=mirror_ubuntu-bionic-kernel.git 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 Signed-off-by: Steffen Klassert --- 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;