Skip to content

Commit 1e532d2

Browse files
committed
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>
1 parent 374d1b5 commit 1e532d2

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎net/key/af_key.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2202,8 +2202,10 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, const struct km_ev
22022202
return PTR_ERR(out_skb);
22032203

22042204
err = pfkey_xfrm_policy2msg(out_skb, xp, dir);
2205-
if (err < 0)
2205+
if (err < 0) {
2206+
kfree_skb(out_skb);
22062207
return err;
2208+
}
22072209

22082210
out_hdr = (struct sadb_msg *) out_skb->data;
22092211
out_hdr->sadb_msg_version = PF_KEY_V2;

0 commit comments

Comments
 (0)