If store_mem_state() is called to online memory which is already online, it will return 1, the value it got from device_online().
This is wrong because store_mem_state() is a device_attribute .store function. Thus a non-negative return value represents input bytes read. Set the return value to -EINVAL in this case. Signed-off-by: Reza Arbab <[email protected]> --- v2 -> v3: * David Rientjes pointed out that the backwards-compatible return value in this situation is -EINVAL, not success. I had mistakenly thought the behavior should be the same as online_store(). drivers/base/memory.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 1cea0ba..bb69e58 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -359,8 +359,11 @@ store_mem_state(struct device *dev, err: unlock_device_hotplug(); - if (ret) + if (ret < 0) return ret; + if (ret) + return -EINVAL; + return count; } -- 1.8.3.1

