diff mbox series

[net] net: ipv6: rpl_iptunnel: Fix memory leak in rpl_input

Message ID 20240911174557.11536-1-justin.iurman@uliege.be (mailing list archive)
State Accepted
Commit 2c84b0aa28b9e73e8c4b4ce038269469434ae372
Delegated to: Netdev Maintainers
Headers show
Series [net] net: ipv6: rpl_iptunnel: Fix memory leak in rpl_input | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 16 this patch: 16
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-09-12--15-00 (tests: 764)

Commit Message

Justin Iurman Sept. 11, 2024, 5:45 p.m. UTC
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>
---
 net/ipv6/rpl_iptunnel.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Simon Horman Sept. 12, 2024, 10:42 a.m. UTC | #1
On Wed, Sep 11, 2024 at 07:45:57PM +0200, Justin Iurman wrote:
> 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>

...
patchwork-bot+netdevbpf@kernel.org Sept. 14, 2024, 3:10 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 11 Sep 2024 19:45:57 +0200 you wrote:
> 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>
> ---
>  net/ipv6/rpl_iptunnel.c | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)

Here is the summary with links:
  - [net] net: ipv6: rpl_iptunnel: Fix memory leak in rpl_input
    https://git.kernel.org/netdev/net/c/2c84b0aa28b9

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv6/rpl_iptunnel.c b/net/ipv6/rpl_iptunnel.c
index 2c83b7586422..db3c19a42e1c 100644
--- a/net/ipv6/rpl_iptunnel.c
+++ b/net/ipv6/rpl_iptunnel.c
@@ -263,10 +263,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);
@@ -286,9 +284,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,