Skip to contentSkip to conversation

sysfs:Addresses documentation in sysfs_merge_group and sysfs_unmerge_group.

PATCH New Rohan Kollambalath 1 participant 1 message Feb 11, 2024 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sysfs:Addresses documentation in sysfs_merge_group and sysfs_unmerge_group.

From: Rohan Kollambalath <[email protected]>

These functions take a struct attribute_group as an input which has an optional .name field. These functions rely on the .name field being populated and do not check if its null. They pass this name into other functions, eventually leading to a null pointer dereference.

This change simply updates the documentation of the function to make this requirement clear.

---
 fs/sysfs/group.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
fs/sysfs/group.c +5 -5
index 138676463336..8a22444dd46a 100644
@@ -318,13 +318,13 @@ void sysfs_remove_groups(struct kobject *kobj,
 EXPORT_SYMBOL_GPL(sysfs_remove_groups);
 
 /**
- * sysfs_merge_group - merge files into a pre-existing attribute group.
+ * sysfs_merge_group - merge files into a pre-existing named attribute group.
  * @kobj:	The kobject containing the group.
  * @grp:	The files to create and the attribute group they belong to.
  *
- * This function returns an error if the group doesn't exist or any of the
- * files already exist in that group, in which case none of the new files
- * are created.
+ * This function returns an error if the group doesn't exist, the .name field is
+ * NULL or any of the files already exist in that group, in which case none of
+ * the new files are created.
  */
 int sysfs_merge_group(struct kobject *kobj,
 		       const struct attribute_group *grp)
@@ -356,7 +356,7 @@ int sysfs_merge_group(struct kobject *kobj,
 EXPORT_SYMBOL_GPL(sysfs_merge_group);
 
 /**
- * sysfs_unmerge_group - remove files from a pre-existing attribute group.
+ * sysfs_unmerge_group - remove files from a pre-existing named attribute group.
  * @kobj:	The kobject containing the group.
  * @grp:	The files to remove and the attribute group they belong to.
  */
Signature · 1 line
2.25.1