diff mbox series

[1/2] net/smc: Return directly after a failed kzalloc() in smc_fill_gid_list()

Message ID f02303c3-5968-48c3-990b-be0be8a66521@web.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net/smc: 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 10 of 10 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, 8 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 Dec. 31, 2023, 2:58 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 31 Dec 2023 15:15:19 +0100

The kfree() function was called in one case by
the smc_fill_gid_list() 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 call of the function “kzalloc” failed
at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/smc/af_smc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
2.43.0

Comments

Tony Lu Jan. 2, 2024, 2:13 a.m. UTC | #1
On Sun, Dec 31, 2023 at 03:58:15PM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 31 Dec 2023 15:15:19 +0100
> 
> The kfree() function was called in one case by
> the smc_fill_gid_list() 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 call of the function "kzalloc" failed
> at the beginning.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

LGTM, thank you.

Also please add net tag in subject and fixes tag in commit body.

Reviewed-by: Tony Lu <tonylu@linux.alibaba.com>

> ---
>  net/smc/af_smc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> index 7fc2f3c6d248..a396a9977ba9 100644
> --- a/net/smc/af_smc.c
> +++ b/net/smc/af_smc.c
> @@ -1180,7 +1180,7 @@ void smc_fill_gid_list(struct smc_link_group *lgr,
> 
>  	alt_ini = kzalloc(sizeof(*alt_ini), GFP_KERNEL);
>  	if (!alt_ini)
> -		goto out;
> +		return;
> 
>  	alt_ini->vlan_id = lgr->vlan_id;
>  	alt_ini->check_smcrv2 = true;
> --
> 2.43.0
diff mbox series

Patch

diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 7fc2f3c6d248..a396a9977ba9 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -1180,7 +1180,7 @@  void smc_fill_gid_list(struct smc_link_group *lgr,

 	alt_ini = kzalloc(sizeof(*alt_ini), GFP_KERNEL);
 	if (!alt_ini)
-		goto out;
+		return;

 	alt_ini->vlan_id = lgr->vlan_id;
 	alt_ini->check_smcrv2 = true;