xfrm: free skb if nlsk pointer is NULL

[ Upstream commit 86126b77dc ]

nlmsg_multicast() always frees the skb, so in case we cannot call
it we must do that ourselves.

Fixes: 21ee543edc ("xfrm: fix race between netns cleanup and state expire notification")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Florian Westphal
2018-06-25 14:00:07 +02:00
committed by Greg Kroah-Hartman
parent dbcad9a65d
commit d9c00c8959

View File

@ -980,10 +980,12 @@ static inline int xfrm_nlmsg_multicast(struct net *net, struct sk_buff *skb,
{ {
struct sock *nlsk = rcu_dereference(net->xfrm.nlsk); struct sock *nlsk = rcu_dereference(net->xfrm.nlsk);
if (nlsk) if (!nlsk) {
return nlmsg_multicast(nlsk, skb, pid, group, GFP_ATOMIC); kfree_skb(skb);
else return -EPIPE;
return -1; }
return nlmsg_multicast(nlsk, skb, pid, group, GFP_ATOMIC);
} }
static inline size_t xfrm_spdinfo_msgsize(void) static inline size_t xfrm_spdinfo_msgsize(void)