[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240914081523.798940-1-andreas@kemnade.info>
Date: Sat, 14 Sep 2024 10:15:23 +0200
From: Andreas Kemnade <andreas@...nade.info>
To: sre@...nel.org,
linux@...ssschuh.net,
linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org,
hns@...delico.com
Cc: Andreas Kemnade <andreas@...nade.info>,
stable@...r.kernel.org
Subject: [PATCH] power: supply: sysfs: enable is_writeable check during sysfs creation
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@...nade.info>
Cc: stable@...r.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
Powered by blists - more mailing lists