[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b9e00c7c-2c74-4de4-a794-df3338059a03@web.de>
Date: Sun, 31 Dec 2023 09:42:24 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: Peter Oberparleiter <oberpar@...ux.ibm.com>,
kernel-janitors@...r.kernel.org
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 2/3] gcov: Return directly after a failed kzalloc() in
new_node()
From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Sun, 31 Dec 2023 09:12:44 +0100
The kfree() function was called in one case by
the new_node() 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@...rs.sourceforge.net>
---
kernel/gcov/fs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/gcov/fs.c b/kernel/gcov/fs.c
index 0fbfa444a388..10916c70fad9 100644
--- a/kernel/gcov/fs.c
+++ b/kernel/gcov/fs.c
@@ -543,7 +543,8 @@ static struct gcov_node *new_node(struct gcov_node *parent,
node = kzalloc(sizeof(struct gcov_node) + strlen(name) + 1, GFP_KERNEL);
if (!node)
- goto err_nomem;
+ return NULL;
+
if (info) {
node->loaded_info = kcalloc(1, sizeof(struct gcov_info *),
GFP_KERNEL);
--
2.43.0
Powered by blists - more mailing lists