diff mbox series

[1/2] batman-adv: Return directly after a failed batadv_dat_select_candidates() in batadv_dat_forward_data()

Message ID 54dc53f8-5f08-4f1d-938a-c845c8ec0d44@web.de (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series batman-adv: Adjustments for two function implementations | expand

Checks

Context Check Description
netdev/series_format warning Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1113 this patch: 1113
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 1140 this patch: 1140
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 No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1140 this patch: 1140
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 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

Commit Message

Markus Elfring Jan. 2, 2024, 7:11 a.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 2 Jan 2024 07:27:45 +0100

The kfree() function was called in one case by
the batadv_dat_forward_data() function during error handling
even if the passed variable contained a null pointer.
This issue was detected by using the Coccinelle software.

* Thus return directly after a batadv_dat_select_candidates() call failed
  at the beginning.

* Delete the label “out” which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/batman-adv/distributed-arp-table.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--
2.43.0

Comments

Sven Eckelmann Jan. 2, 2024, 11:22 a.m. UTC | #1
On Tuesday, 2 January 2024 08:11:47 CET Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 2 Jan 2024 07:27:45 +0100
> 
> The kfree() function was called in one case by
> the batadv_dat_forward_data() function during error handling
> even if the passed variable contained a null pointer.
> This issue was detected by using the Coccinelle software.
> 
> * Thus return directly after a batadv_dat_select_candidates() call failed
>   at the beginning.
> 
> * Delete the label “out” which became unnecessary with this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Acked-by: Sven Eckelmann <sven@narfation.org>

> ---
>  net/batman-adv/distributed-arp-table.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
> index 28a939d56090..4c7e85534324 100644
> --- a/net/batman-adv/distributed-arp-table.c
> +++ b/net/batman-adv/distributed-arp-table.c
> @@ -684,7 +684,7 @@ static bool batadv_dat_forward_data(struct batadv_priv *bat_priv,
> 
>  	cand = batadv_dat_select_candidates(bat_priv, ip, vid);
>  	if (!cand)
> -		goto out;
> +		return ret;
> 
>  	batadv_dbg(BATADV_DBG_DAT, bat_priv, "DHT_SEND for %pI4\n", &ip);
> 
> @@ -728,7 +728,6 @@ static bool batadv_dat_forward_data(struct batadv_priv *bat_priv,
>  		batadv_orig_node_put(cand[i].orig_node);
>  	}
> 
> -out:
>  	kfree(cand);
>  	return ret;
>  }
> --
> 2.43.0
> 
>
diff mbox series

Patch

diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 28a939d56090..4c7e85534324 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -684,7 +684,7 @@  static bool batadv_dat_forward_data(struct batadv_priv *bat_priv,

 	cand = batadv_dat_select_candidates(bat_priv, ip, vid);
 	if (!cand)
-		goto out;
+		return ret;

 	batadv_dbg(BATADV_DBG_DAT, bat_priv, "DHT_SEND for %pI4\n", &ip);

@@ -728,7 +728,6 @@  static bool batadv_dat_forward_data(struct batadv_priv *bat_priv,
 		batadv_orig_node_put(cand[i].orig_node);
 	}

-out:
 	kfree(cand);
 	return ret;
 }