Skip to content

Commit 876f8ab

Browse files
Dan Carpenterkuba-moo
authored andcommitted
hsr: Prevent use after free in prp_create_tagged_frame()
The prp_fill_rct() function can fail. In that situation, it frees the skb and returns NULL. Meanwhile on the success path, it returns the original skb. So it's straight forward to fix bug by using the returned value. Fixes: 451d812 ("net: prp: add packet handling support") Signed-off-by: Dan Carpenter <[email protected]> Acked-by: Paolo Abeni <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7b3ba18 commit 876f8ab

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

net/hsr/hsr_forward.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,7 @@ struct sk_buff *prp_create_tagged_frame(struct hsr_frame_info *frame,
342342
skb = skb_copy_expand(frame->skb_std, 0,
343343
skb_tailroom(frame->skb_std) + HSR_HLEN,
344344
GFP_ATOMIC);
345-
prp_fill_rct(skb, frame, port);
346-
347-
return skb;
345+
return prp_fill_rct(skb, frame, port);
348346
}
349347

350348
static void hsr_deliver_master(struct sk_buff *skb, struct net_device *dev,

0 commit comments

Comments
 (0)