mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Peter Oberparleiter <oberpar@linux.ibm.com>,
	kernel-janitors@vger.kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/3] gcov: Return directly after a failed kzalloc() in new_node()
Date: Sun, 31 Dec 2023 09:42:24 +0100	[thread overview]
Message-ID: <b9e00c7c-2c74-4de4-a794-df3338059a03@web.de> (raw)
In-Reply-To: <ebffa8ea-8d0c-4b83-805b-754e25bd4603@web.de>

From: Markus Elfring <elfring@users.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@users.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


  parent reply	other threads:[~2023-12-31  8:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-31  8:39 [PATCH 0/3] gcov: Adjustments for two function implementations Markus Elfring
2023-12-31  8:41 ` [PATCH 1/3] gcov: Delete an error message for a failed memory allocation in new_node() Markus Elfring
2023-12-31  8:42 ` Markus Elfring [this message]
2023-12-31  8:43 ` [PATCH 3/3] gcov: Improve exception handling in add_links() Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b9e00c7c-2c74-4de4-a794-df3338059a03@web.de \
    --to=markus.elfring@web.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oberpar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®