lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120911111333.GD22259@elgon.mountain>
Date:	Tue, 11 Sep 2012 14:13:33 +0300
From:	Dan Carpenter <dan.carpenter@...cle.com>
To:	linux-kernel@...r.kernel.org,
	Peter Oberparleiter <oberpar@...ux.vnet.ibm.com>
Cc:	kernel-janitors@...r.kernel.org
Subject: [patch] gcov: cleanup an allocation in new_node()

1) kcalloc(1, ...) can be replaced with kzalloc().
2) There was a small leak if the debugfs_create_dir() fails.
3) I removed a pr_warning("out of memory\n") because kmalloc() already
   prints a more useful failure message in the unlikely case of an
   allocation failure.

Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>

diff --git a/kernel/gcov/fs.c b/kernel/gcov/fs.c
index 9bd0934..132168f 100644
--- a/kernel/gcov/fs.c
+++ b/kernel/gcov/fs.c
@@ -437,7 +437,7 @@ static struct gcov_node *new_node(struct gcov_node *parent,
 	if (!node)
 		goto err_nomem;
 	if (info) {
-		node->loaded_info = kcalloc(1, sizeof(struct gcov_info *),
+		node->loaded_info = kzalloc(sizeof(struct gcov_info *),
 					   GFP_KERNEL);
 		if (!node->loaded_info)
 			goto err_nomem;
@@ -451,8 +451,7 @@ static struct gcov_node *new_node(struct gcov_node *parent,
 		node->dentry = debugfs_create_dir(node->name, parent->dentry);
 	if (!node->dentry) {
 		pr_warning("could not create file\n");
-		kfree(node);
-		return NULL;
+		goto err_info;
 	}
 	if (info)
 		add_links(node, parent->dentry);
@@ -461,9 +460,11 @@ static struct gcov_node *new_node(struct gcov_node *parent,
 
 	return node;
 
+err_info:
+	if (info)
+		kfree(node->loaded_info);
 err_nomem:
 	kfree(node);
-	pr_warning("out of memory\n");
 	return NULL;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ