From: Hans de Goede <hdegoede@redhat.com>
To: Sebastian Reichel <sre@kernel.org>
Cc: "Hans de Goede" <hdegoede@redhat.com>,
linux-pm@vger.kernel.org,
"Thomas Weißschuh" <linux@weissschuh.net>
Subject: [PATCH 6.11 regression fix] power: supply: sysfs: Revert use power_supply_property_is_writeable()
Date: Sun, 8 Sep 2024 16:44:14 +0200 [thread overview]
Message-ID: <20240908144414.82887-1-hdegoede@redhat.com> (raw)
power_supply_property_is_writeable() contains the following check:
if (atomic_read(&psy->use_cnt) <= 0 ||
!psy->desc->property_is_writeable)
return -ENODEV;
psy->use_cnt gets initialized to 0 and is incremented by
__power_supply_register() after it calls device_add(); and thus after
the driver core calls power_supply_attr_is_visible() to get the attr's
permissions.
So when power_supply_attr_is_visible() runs psy->use_cnt is 0 failing
the above check. This is causing all the attributes to have permissions
of 444 even those which should be writable.
Move back to manually calling psy->desc->property_is_writeable() without
the psy->use_cnt check to fix this.
Fixes: be6299c6e55e ("power: supply: sysfs: use power_supply_property_is_writeable()")
Cc: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Note this is a straight-forward revert of be6299c6e55e
---
drivers/power/supply/power_supply_sysfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c
index 6cd3fac1891b..fb9b67b5a9aa 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -387,7 +387,8 @@ static umode_t power_supply_attr_is_visible(struct kobject *kobj,
int property = psy->desc->properties[i];
if (property == attrno) {
- if (power_supply_property_is_writeable(psy, property) > 0)
+ if (psy->desc->property_is_writeable &&
+ psy->desc->property_is_writeable(psy, property) > 0)
mode |= S_IWUSR;
return mode;
--
2.46.0
next reply other threads:[~2024-09-08 14:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-08 14:44 Hans de Goede [this message]
2024-09-08 14:52 ` [PATCH 6.11 regression fix] power: supply: sysfs: Revert use power_supply_property_is_writeable() Thomas Weißschuh
2024-09-08 16:38 ` Hans de Goede
2024-09-08 17:28 ` Thomas Weißschuh
2024-09-08 18:42 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240908144414.82887-1-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=linux-pm@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=sre@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox