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>] [day] [month] [year] [list]
Date:	Wed, 14 Jul 2010 17:37:26 +0800
From:	Changli Gao <xiaosuo@...il.com>
To:	Greg Kroah-Hartman <gregkh@...e.de>
Cc:	"Jike Song" <albcamus@...il.com>, linux-kernel@...r.kernel.org,
	Changli Gao <xiaosuo@...il.com>
Subject: [PATCH] drivers: code cleanups

drivers: code cleanups

the first three goto clauses caused kfree(NULL), and the error code returned
by kset->uevent_ops->uevent() wasn't passed to the caller of show_uevent().
This patch also eliminates the unnecessary initializations of env and count.

Signed-off-by: Changli Gao <xiaosuo@...il.com>
----
 drivers/base/core.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 38bbbd0..33fa36d 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -274,9 +274,8 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
 {
 	struct kobject *top_kobj;
 	struct kset *kset;
-	struct kobj_uevent_env *env = NULL;
+	struct kobj_uevent_env *env;
 	int i;
-	size_t count = 0;
 	int retval;
 
 	/* search the kset, the device belongs to */
@@ -284,16 +283,16 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
 	while (!top_kobj->kset && top_kobj->parent)
 		top_kobj = top_kobj->parent;
 	if (!top_kobj->kset)
-		goto out;
+		return 0;
 
 	kset = top_kobj->kset;
 	if (!kset->uevent_ops || !kset->uevent_ops->uevent)
-		goto out;
+		return 0;
 
 	/* respect filter */
 	if (kset->uevent_ops && kset->uevent_ops->filter)
 		if (!kset->uevent_ops->filter(kset, &dev->kobj))
-			goto out;
+			return 0;
 
 	env = kzalloc(sizeof(struct kobj_uevent_env), GFP_KERNEL);
 	if (!env)
@@ -305,11 +304,12 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
 		goto out;
 
 	/* copy keys to file */
+	retval = 0;
 	for (i = 0; i < env->envp_idx; i++)
-		count += sprintf(&buf[count], "%s\n", env->envp[i]);
+		retval += sprintf(&buf[retval], "%s\n", env->envp[i]);
 out:
 	kfree(env);
-	return count;
+	return retval;
 }
 
 static ssize_t store_uevent(struct device *dev, struct device_attribute *attr,
--
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