Skip to content

Commit

Permalink
memory-hotplug: fix store_mem_state() return value
Browse files Browse the repository at this point in the history
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.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Reza Arbab <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Vitaly Kuznetsov <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Yaowei Bai <[email protected]>
Cc: Joonsoo Kim <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: Xishi Qiu <[email protected]>
Cc: David Vrabel <[email protected]>
Cc: Chen Yucong <[email protected]>
Cc: Andrew Banman <[email protected]>
Cc: Seth Jennings <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
rarbab authored and torvalds committed Oct 8, 2016
1 parent 0247f3f commit d66ba15
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/base/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,11 @@ store_mem_state(struct device *dev,
err:
unlock_device_hotplug();

if (ret)
if (ret < 0)
return ret;
if (ret)
return -EINVAL;

return count;
}

Expand Down

0 comments on commit d66ba15

Please sign in to comment.