Skip to content

Commit c254637

Browse files
miniplidavem330
authored andcommitted
xfrm_user: return error pointer instead of NULL #2
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>
1 parent 864745d commit c254637

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

net/xfrm/xfrm_user.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,7 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb,
15481548
{
15491549
struct xfrm_dump_info info;
15501550
struct sk_buff *skb;
1551+
int err;
15511552

15521553
skb = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
15531554
if (!skb)
@@ -1558,9 +1559,10 @@ static struct sk_buff *xfrm_policy_netlink(struct sk_buff *in_skb,
15581559
info.nlmsg_seq = seq;
15591560
info.nlmsg_flags = 0;
15601561

1561-
if (dump_one_policy(xp, dir, 0, &info) < 0) {
1562+
err = dump_one_policy(xp, dir, 0, &info);
1563+
if (err) {
15621564
kfree_skb(skb);
1563-
return NULL;
1565+
return ERR_PTR(err);
15641566
}
15651567

15661568
return skb;

0 commit comments

Comments
 (0)