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-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 17 Aug 2011 11:17:01 +0100
From:	Jonathan Cameron <jic23@....ac.uk>
To:	linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:	greg@...ah.com, Jonathan Cameron <jic23@....ac.uk>
Subject: [PATCH 1/2] sysfs: Allow for null group pointer in create_group

Needed for the case where all files are added separately rather than
as a group.

Usecase - iio_chan_spec based registration of IIO devices where
in some drivers all sysfs attributes are generated from these
descriptive structures on probe rather than using a static table.

Signed-off-by: Jonathan Cameron <jic23@....ac.uk>
---
 fs/sysfs/group.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index 194414f..65d6d78 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -68,17 +68,19 @@ static int internal_create_group(struct kobject *kobj, int update,
 	if (unlikely(update && !kobj->sd))
 		return -EINVAL;
 
-	if (grp->name) {
+	if (grp && grp->name) {
 		error = sysfs_create_subdir(kobj, grp->name, &sd);
 		if (error)
 			return error;
 	} else
 		sd = kobj->sd;
 	sysfs_get(sd);
-	error = create_files(sd, kobj, grp, update);
-	if (error) {
-		if (grp->name)
-			sysfs_remove_subdir(sd);
+	if (grp) {
+		error = create_files(sd, kobj, grp, update);
+		if (error) {
+			if (grp->name)
+				sysfs_remove_subdir(sd);
+		}
 	}
 	sysfs_put(sd);
 	return error;
@@ -131,7 +133,7 @@ void sysfs_remove_group(struct kobject * kobj,
 	struct sysfs_dirent *dir_sd = kobj->sd;
 	struct sysfs_dirent *sd;
 
-	if (grp->name) {
+	if (grp && grp->name) {
 		sd = sysfs_get_dirent(dir_sd, NULL, grp->name);
 		if (!sd) {
 			WARN(!sd, KERN_WARNING "sysfs group %p not found for "
@@ -140,11 +142,11 @@ void sysfs_remove_group(struct kobject * kobj,
 		}
 	} else
 		sd = sysfs_get(dir_sd);
-
-	remove_files(sd, kobj, grp);
-	if (grp->name)
-		sysfs_remove_subdir(sd);
-
+	if (grp) {
+	 	remove_files(sd, kobj, grp);
+		if (grp->name)
+			sysfs_remove_subdir(sd);
+	}
 	sysfs_put(sd);
 }
 
-- 
1.7.3.4

--
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