Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Andi Kleen and committed by
Greg Kroah-Hartman
4e318d7c 65151365

+4 -2
+4 -2
drivers/base/sys.c
··· 488 488 if (end == buf) 489 489 return -EINVAL; 490 490 *(unsigned long *)(ea->var) = new; 491 - return end - buf; 491 + /* Always return full write size even if we didn't consume all */ 492 + return size; 492 493 } 493 494 EXPORT_SYMBOL_GPL(sysdev_store_ulong); 494 495 ··· 512 511 if (end == buf || new > INT_MAX || new < INT_MIN) 513 512 return -EINVAL; 514 513 *(int *)(ea->var) = new; 515 - return end - buf; 514 + /* Always return full write size even if we didn't consume all */ 515 + return size; 516 516 } 517 517 EXPORT_SYMBOL_GPL(sysdev_store_int); 518 518