]> git.itanic.dy.fi Git - linux-stable/commitdiff
hsr: Prevent use after free in prp_create_tagged_frame()
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 27 Oct 2023 12:19:01 +0000 (15:19 +0300)
committerJakub Kicinski <kuba@kernel.org>
Thu, 2 Nov 2023 05:26:04 +0000 (22:26 -0700)
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: 451d8123f897 ("net: prp: add packet handling support")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Link: https://lore.kernel.org/r/57af1f28-7f57-4a96-bcd3-b7a0f2340845@moroto.mountain
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/hsr/hsr_forward.c

index b71dab630a8732de385fb07694149d7e69a7151c..80cdc6f6b34c97601961179c4839dc68c0a6d2e1 100644 (file)
@@ -342,9 +342,7 @@ struct sk_buff *prp_create_tagged_frame(struct hsr_frame_info *frame,
        skb = skb_copy_expand(frame->skb_std, 0,
                              skb_tailroom(frame->skb_std) + HSR_HLEN,
                              GFP_ATOMIC);
-       prp_fill_rct(skb, frame, port);
-
-       return skb;
+       return prp_fill_rct(skb, frame, port);
 }
 
 static void hsr_deliver_master(struct sk_buff *skb, struct net_device *dev,