diff mbox series

[2/2] net/iucv: Improve error handling in iucv_enable()

Message ID d4b65eeb-0ded-4a04-a58e-496a7609edb3@web.de (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series net/iucv: Adjustments for iucv_enable() | 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: 8 this patch: 8
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
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: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 25 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. 1, 2024, 9 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 1 Jan 2024 21:44:46 +0100

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

* Thus achieve an unlock operation by using the corresponding label.

* Move two error code assignments to other places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/iucv/iucv.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

--
2.43.0
diff mbox series

Patch

diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
index 71ba309e05ee..09e78a57bab8 100644
--- a/net/iucv/iucv.c
+++ b/net/iucv/iucv.c
@@ -543,13 +543,14 @@  static int iucv_enable(void)
 	int cpu, rc;

 	cpus_read_lock();
-	rc = -ENOMEM;
 	alloc_size = iucv_max_pathid * sizeof(struct iucv_path);
 	iucv_path_table = kzalloc(alloc_size, GFP_KERNEL);
-	if (!iucv_path_table)
-		goto out;
+	if (!iucv_path_table) {
+		rc = -ENOMEM;
+		goto unlock;
+	}
+
 	/* Declare per cpu buffers. */
-	rc = -EIO;
 	for_each_online_cpu(cpu)
 		smp_call_function_single(cpu, iucv_declare_cpu, NULL, 1);
 	if (cpumask_empty(&iucv_buffer_cpumask))
@@ -564,6 +565,7 @@  static int iucv_enable(void)
 out:
 	kfree(iucv_path_table);
 	iucv_path_table = NULL;
+	rc = -EIO;
 	goto unlock;
 }