[PATCH 2/3] gcov: Return directly after a failed kzalloc() in new_node()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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






[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux