Skip to contentSkip to conversation

SYSFS: Fix return values for sysdev_store_{ulong,int}

PATCH In review Andi Kleen 2 participants 3 messages Oct 13, 2008 – Oct 17, 2008 Driver core

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 SYSFS: Fix return values for sysdev_store_{ulong,int}

SYSFS: Fix return values for sysdev_store_{ulong,int}

Always return the full size instead of the consumed length of the string in sysdev_store_{ulong,int}

This avoids EINVAL errors in some echo versions.

drivers/base/sys.c +4 -2
Index: linux/drivers/base/sys.c
===================================================================
@@ -488,7 +488,8 @@ ssize_t sysdev_store_ulong(struct sys_de
 	if (end == buf)
 		return -EINVAL;
 	*(unsigned long *)(ea->var) = new;
-	return end - buf;
+	/* Always return full write size even if we didn't consume all */
+	return size;
 }
 EXPORT_SYMBOL_GPL(sysdev_store_ulong);
 
@@ -511,7 +512,8 @@ ssize_t sysdev_store_int(struct sys_devi
 	if (end == buf || new > INT_MAX || new < INT_MIN)
 		return -EINVAL;
 	*(int *)(ea->var) = new;
-	return end - buf;
+	/* Always return full write size even if we didn't consume all */
+	return size;
 }
 EXPORT_SYMBOL_GPL(sysdev_store_int);
 
#1 lore raw
Quoted 6 lines · On Mon, 13 Oct 2008 12:03:03 +0200 Andi Kleen <[email protected]> wrote:

SYSFS: Fix return values for sysdev_store_{ulong,int}

Always return the full size instead of the consumed length of the string in sysdev_store_{ulong,int}

This avoids EINVAL errors in some echo versions.

That sounds fairly serious. Is this a regression or are those versions of echo really ancient, or...?

author
#2 lore raw
Quoted 5 lines · Andrew Morton
Quoted 2 lines · On Mon, 13 Oct 2008 12:03:03 +0200 Andi Kleen <[email protected]> wrote:

SYSFS: Fix return values for sysdev_store_{ulong,int}

Quoted 7 lines
Quoted 4 lines

Always return the full size instead of the consumed length of the string in sysdev_store_{ulong,int}

This avoids EINVAL errors in some echo versions.

That sounds fairly serious. Is this a regression or are those versions of echo really ancient, or...?

It's a regression, but it currently only affects the mce sysfs files, which are the only ones using it. Also the EINVAL is more a cosmetic issue because the first write will already change the value successfully, only the second one will fail but not change anything.

-Andi

Signature · 1 line
[email protected]