git: bf876046e4b1 - main - linuxkpi: Fix sysfs_remove_group() for groups without a name
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 04 Nov 2026 06:36:24 UTC
The branch main has been updated by manu:
URL: https://cgit.FreeBSD.org/src/commit/?id=bf876046e4b13c348de0414a69184026678bbf10
commit bf876046e4b13c348de0414a69184026678bbf10
Author: Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2026-10-28 11:17:37 +0000
Commit: Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2026-11-04 06:33:43 +0000
linuxkpi: Fix sysfs_remove_group() for groups without a name
sysfs_create_group() handles a group with a NULL name by creating its
attributes directly under the object node, but sysfs_remove_group() passed
the NULL name to sysctl_remove_name(), which then panics in strcmp().
Mirror the creation path: for an unnamed group, remove each attribute and
binary attribute individually.
This was not hit before because the devres actions of a PCI device
(e.g. the one registered by devm_device_add_group()) were not run when
the driver was detached.
Sponsored by: Beckhoff Automation Gmbh & Co. KG
---
sys/compat/linuxkpi/common/include/linux/sysfs.h | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/sys/compat/linuxkpi/common/include/linux/sysfs.h b/sys/compat/linuxkpi/common/include/linux/sysfs.h
index 4aea46d6b120..e21498c41617 100644
--- a/sys/compat/linuxkpi/common/include/linux/sysfs.h
+++ b/sys/compat/linuxkpi/common/include/linux/sysfs.h
@@ -403,9 +403,22 @@ sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp)
static inline void
sysfs_remove_group(struct kobject *kobj, const struct attribute_group *grp)
{
+ struct attribute **attr;
+ struct bin_attribute **bin_attr;
- if (kobj->oidp)
+ if (kobj->oidp == NULL)
+ return;
+
+ /* Mirror sysfs_create_group(): unnamed groups live directly under kobj. */
+ if (grp->name != NULL) {
sysctl_remove_name(kobj->oidp, grp->name, 1, 1);
+ return;
+ }
+ for (attr = grp->attrs; attr != NULL && *attr != NULL; attr++)
+ sysctl_remove_name(kobj->oidp, (*attr)->name, 1, 1);
+ for (bin_attr = grp->bin_attrs; bin_attr != NULL && *bin_attr != NULL;
+ bin_attr++)
+ sysctl_remove_name(kobj->oidp, (*bin_attr)->attr.name, 1, 1);
}
static inline int