mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] power: supply: sysfs: enable is_writeable check during sysfs creation
@ 2024-09-14  8:15 Andreas Kemnade
  2024-09-14  8:28 ` Thomas Weißschuh
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Kemnade @ 2024-09-14  8:15 UTC (permalink / raw)
  To: sre, linux, linux-pm, linux-kernel, hns; +Cc: Andreas Kemnade, stable

The files in sysfs are created during device_add(). psy->use_cnt
is not incremented yet. So attributes are created readonly
without checking desc->property_is_writeable() and writeable
files are readonly.

To fix this, revert back to calling desc->property_is_writeable()
directly without using the helper.

Fixes: be6299c6e55e ("power: supply: sysfs: use power_supply_property_is_writeable()")
Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Cc: stable@vger.kernel.org # 6.11
---
 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 3e63d165b2f70..b86e11bdc07ef 100644
--- a/drivers/power/supply/power_supply_sysfs.c
+++ b/drivers/power/supply/power_supply_sysfs.c
@@ -379,7 +379,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.39.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-14  8:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-14  8:15 [PATCH] power: supply: sysfs: enable is_writeable check during sysfs creation Andreas Kemnade
2024-09-14  8:28 ` Thomas Weißschuh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®