Commit d4782c32 authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[AF_KEY]: Fix skb leak on pfkey_send_migrate() error

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 421c9914
...@@ -3593,27 +3593,29 @@ static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type, ...@@ -3593,27 +3593,29 @@ static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
/* old ipsecrequest */ /* old ipsecrequest */
int mode = pfkey_mode_from_xfrm(mp->mode); int mode = pfkey_mode_from_xfrm(mp->mode);
if (mode < 0) if (mode < 0)
return -EINVAL; goto err;
if (set_ipsecrequest(skb, mp->proto, mode, if (set_ipsecrequest(skb, mp->proto, mode,
(mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE), (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE),
mp->reqid, mp->old_family, mp->reqid, mp->old_family,
&mp->old_saddr, &mp->old_daddr) < 0) { &mp->old_saddr, &mp->old_daddr) < 0)
return -EINVAL; goto err;
}
/* new ipsecrequest */ /* new ipsecrequest */
if (set_ipsecrequest(skb, mp->proto, mode, if (set_ipsecrequest(skb, mp->proto, mode,
(mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE), (mp->reqid ? IPSEC_LEVEL_UNIQUE : IPSEC_LEVEL_REQUIRE),
mp->reqid, mp->new_family, mp->reqid, mp->new_family,
&mp->new_saddr, &mp->new_daddr) < 0) { &mp->new_saddr, &mp->new_daddr) < 0)
return -EINVAL; goto err;
}
} }
/* broadcast migrate message to sockets */ /* broadcast migrate message to sockets */
pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL); pfkey_broadcast(skb, GFP_ATOMIC, BROADCAST_ALL, NULL);
return 0; return 0;
err:
kfree_skb(skb);
return -EINVAL;
} }
#else #else
static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type, static int pfkey_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment