]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: ipv6: rpl_iptunnel: Fix memory leak in rpl_input
authorJustin Iurman <justin.iurman@uliege.be>
Wed, 11 Sep 2024 17:45:57 +0000 (19:45 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Oct 2024 13:07:42 +0000 (15:07 +0200)
[ Upstream commit 2c84b0aa28b9e73e8c4b4ce038269469434ae372 ]

Free the skb before returning from rpl_input when skb_cow_head() fails.
Use a "drop" label and goto instructions.

Fixes: a7a29f9c361f ("net: ipv6: add rpl sr tunnel")
Signed-off-by: Justin Iurman <justin.iurman@uliege.be>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240911174557.11536-1-justin.iurman@uliege.be
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv6/rpl_iptunnel.c

index 2ba605db69769823070d5fed1f874ce9b2c34c83..274593b7c6107e06c89185f9bd0a907e6db1cf81 100644 (file)
@@ -268,10 +268,8 @@ static int rpl_input(struct sk_buff *skb)
        rlwt = rpl_lwt_lwtunnel(orig_dst->lwtstate);
 
        err = rpl_do_srh(skb, rlwt);
-       if (unlikely(err)) {
-               kfree_skb(skb);
-               return err;
-       }
+       if (unlikely(err))
+               goto drop;
 
        local_bh_disable();
        dst = dst_cache_get(&rlwt->cache);
@@ -292,9 +290,13 @@ static int rpl_input(struct sk_buff *skb)
 
        err = skb_cow_head(skb, LL_RESERVED_SPACE(dst->dev));
        if (unlikely(err))
-               return err;
+               goto drop;
 
        return dst_input(skb);
+
+drop:
+       kfree_skb(skb);
+       return err;
 }
 
 static int nla_put_rpl_srh(struct sk_buff *skb, int attrtype,