From d66ba15bde22703b3c0cec6782519cb0765a6777 Mon Sep 17 00:00:00 2001 From: Reza Arbab Date: Fri, 7 Oct 2016 17:00:15 -0700 Subject: [PATCH] memory-hotplug: fix store_mem_state() return value 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/1472743777-24266-1-git-send-email-arbab@linux.vnet.ibm.com Signed-off-by: Reza Arbab Cc: Greg Kroah-Hartman Cc: Vlastimil Babka Cc: Vitaly Kuznetsov Cc: David Rientjes Cc: Yaowei Bai Cc: Joonsoo Kim Cc: Dan Williams Cc: Xishi Qiu Cc: David Vrabel Cc: Chen Yucong Cc: Andrew Banman Cc: Seth Jennings Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- 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 dc75de9059cd..62c63c0c5c22 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -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; } -- 2.20.1