[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 1 Jan 2024 22:00:16 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: linux-s390@...r.kernel.org, netdev@...r.kernel.org,
kernel-janitors@...r.kernel.org, Alexandra Winter <wintera@...ux.ibm.com>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Wenjia Zhang <wenjia@...ux.ibm.com>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 2/2] net/iucv: Improve error handling in iucv_enable()
From: Markus Elfring <elfring@...rs.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@...rs.sourceforge.net>
---
net/iucv/iucv.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
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;
}
--
2.43.0
Powered by blists - more mailing lists