Skip to content

Commit 182d22d

Browse files
minipligregkh
authored andcommitted
xfrm_user: return error pointer instead of NULL #2
[ Upstream commit c254637 ] When dump_one_policy() returns an error, e.g. because of a too small buffer to dump the whole xfrm policy, xfrm_policy_netlink() returns NULL instead of an error pointer. But its caller expects an error pointer and therefore continues to operate on a NULL skbuff. Signed-off-by: Mathias Krause <minipli@googlemail.com> Acked-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 66c41c8 commit 182d22d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/xfrm/xfrm_user.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,7 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb,
15311531
{
15321532
struct xfrm_dump_info info;
15331533
struct sk_buff *skb;
1534+
int err;
15341535

15351536
skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
15361537
if (!skb)
@@ -1541,9 +1542,10 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb,
15411542
info.nlmsg_seq = seq;
15421543
info.nlmsg_flags = 0;
15431544

1544-
if (dump_one_policy(xp, dir, 0, &info) < 0) {
1545+
err = dump_one_policy(xp, dir, 0, &info);
1546+
if (err) {
15451547
kfree_skb(skb);
1546-
return NULL;
1548+
return ERR_PTR(err);
15471549
}
15481550

15491551
return skb;

0 commit comments

Comments
 (0)