Skip to content

Commit c0fd973

Browse files
zijun-hugregkh
authored andcommitted
driver core: bus: Return -EIO instead of 0 when show/store invalid bus attribute
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6d8249a commit c0fd973

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/base/bus.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ static ssize_t bus_attr_show(struct kobject *kobj, struct attribute *attr,
152152
{
153153
struct bus_attribute *bus_attr = to_bus_attr(attr);
154154
struct subsys_private *subsys_priv = to_subsys_private(kobj);
155-
ssize_t ret = 0;
155+
/* return -EIO for reading a bus attribute without show() */
156+
ssize_t ret = -EIO;
156157

157158
if (bus_attr->show)
158159
ret = bus_attr->show(subsys_priv->bus, buf);
@@ -164,7 +165,8 @@ static ssize_t bus_attr_store(struct kobject *kobj, struct attribute *attr,
164165
{
165166
struct bus_attribute *bus_attr = to_bus_attr(attr);
166167
struct subsys_private *subsys_priv = to_subsys_private(kobj);
167-
ssize_t ret = 0;
168+
/* return -EIO for writing a bus attribute without store() */
169+
ssize_t ret = -EIO;
168170

169171
if (bus_attr->store)
170172
ret = bus_attr->store(subsys_priv->bus, buf, count);

0 commit comments

Comments
 (0)