* [PATCH v2] driver core: bus: Return -EIO instead of 0 when show/store invalid bus attribute
@ 2024-07-24 13:54 Zijun Hu
2024-07-24 14:06 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Zijun Hu @ 2024-07-24 13:54 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J. Wysocki; +Cc: Zijun Hu, linux-kernel, Zijun Hu
From: Zijun Hu <quic_zijuhu@quicinc.com>
Return -EIO instead of 0 for below erroneous bus attribute operations:
- read a bus attribute without show().
- write a bus attribute without store().
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
Changes in v2:
- Correct commit messages and add inline comments
- The following commit have similar change
Commit: 4a0c20bf8c0f ("[PATCH] sysfs: (driver/base) if show/store is missing return -EIO")
- Link to v1: https://lore.kernel.org/r/20240723-bus_fix-v1-1-175f926805dc@quicinc.com
---
drivers/base/bus.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index ffea0728b8b2..e5073fa82b95 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -152,7 +152,8 @@ static ssize_t bus_attr_show(struct kobject *kobj, struct attribute *attr,
{
struct bus_attribute *bus_attr = to_bus_attr(attr);
struct subsys_private *subsys_priv = to_subsys_private(kobj);
- ssize_t ret = 0;
+ /* return -EIO for reading a bus attribute without show() */
+ ssize_t ret = -EIO;
if (bus_attr->show)
ret = bus_attr->show(subsys_priv->bus, buf);
@@ -164,7 +165,8 @@ static ssize_t bus_attr_store(struct kobject *kobj, struct attribute *attr,
{
struct bus_attribute *bus_attr = to_bus_attr(attr);
struct subsys_private *subsys_priv = to_subsys_private(kobj);
- ssize_t ret = 0;
+ /* return -EIO for writing a bus attribute without store() */
+ ssize_t ret = -EIO;
if (bus_attr->store)
ret = bus_attr->store(subsys_priv->bus, buf, count);
---
base-commit: b57d5ffc3ab507d0e19fc8b90b19c76af43fb790
change-id: 20240723-bus_fix-1940d8e79e92
Best regards,
--
Zijun Hu <quic_zijuhu@quicinc.com>
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v2] driver core: bus: Return -EIO instead of 0 when show/store invalid bus attribute
2024-07-24 13:54 [PATCH v2] driver core: bus: Return -EIO instead of 0 when show/store invalid bus attribute Zijun Hu
@ 2024-07-24 14:06 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2024-07-24 14:06 UTC (permalink / raw)
To: Zijun Hu; +Cc: Rafael J. Wysocki, linux-kernel, Zijun Hu
On Wed, Jul 24, 2024 at 09:54:48PM +0800, Zijun Hu wrote:
> From: Zijun Hu <quic_zijuhu@quicinc.com>
>
> Return -EIO instead of 0 for below erroneous bus attribute operations:
> - read a bus attribute without show().
> - write a bus attribute without store().
>
> Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
> ---
> Changes in v2:
> - Correct commit messages and add inline comments
> - The following commit have similar change
> Commit: 4a0c20bf8c0f ("[PATCH] sysfs: (driver/base) if show/store is missing return -EIO")
> - Link to v1: https://lore.kernel.org/r/20240723-bus_fix-v1-1-175f926805dc@quicinc.com
> ---
> drivers/base/bus.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
Again, how was this tested?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-24 14:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-24 13:54 [PATCH v2] driver core: bus: Return -EIO instead of 0 when show/store invalid bus attribute Zijun Hu
2024-07-24 14:06 ` Greg Kroah-Hartman
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®