Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sysfs: attribute_group: Respect is_visible_const() when changing owner

The call to grp->is_visible in sysfs_group_attrs_change_owner() was
missed when support for is_visible_const() was added.

Check for both is_visible variants there too.

Fixes: 7dd9fdb4939b ("sysfs: attribute_group: enable const variants of is_visible()")
Cc: stable@vger.kernel.org
Reported-by: Michael Kelley <mhklinux@outlook.com>
Closes: https://lore.kernel.org/lkml/SN6PR02MB4157D5F04608E4E3C21AB56ED45EA@SN6PR02MB4157.namprd02.prod.outlook.com/
Link: https://sashiko.dev/#/patchset/20260403-sysfs-const-hv-v2-0-8932ab8d41db%40weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Link: https://patch.msgid.link/20260403-sysfs-is_visible_const-fix-v1-1-f87f26071d2c@weissschuh.net
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

authored by

Thomas Weißschuh and committed by
Danilo Krummrich
9ce4a8c0 8f4c13c2

+5 -2
+5 -2
fs/sysfs/group.c
··· 517 517 struct attribute *const *attr; 518 518 519 519 for (i = 0, attr = grp->attrs; *attr; i++, attr++) { 520 - if (grp->is_visible) { 521 - mode = grp->is_visible(kobj, *attr, i); 520 + if (grp->is_visible || grp->is_visible_const) { 521 + if (grp->is_visible) 522 + mode = grp->is_visible(kobj, *attr, i); 523 + else 524 + mode = grp->is_visible_const(kobj, *attr, i); 522 525 if (mode & SYSFS_GROUP_INVISIBLE) 523 526 break; 524 527 if (!mode)