diff options
author | Reza Arbab <arbab@linux.vnet.ibm.com> | 2016-10-07 20:00:15 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-07 21:46:28 -0400 |
commit | d66ba15bde22703b3c0cec6782519cb0765a6777 (patch) | |
tree | a739a48527e3fd9aeb4f8f0dd160ec5824ce60f8 /drivers/base | |
parent | 0247f3f4d78a475cd3181dc9fc162fdef773aaaa (diff) |
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 <arbab@linux.vnet.ibm.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Xishi Qiu <qiuxishi@huawei.com>
Cc: David Vrabel <david.vrabel@citrix.com>
Cc: Chen Yucong <slaoub@gmail.com>
Cc: Andrew Banman <abanman@sgi.com>
Cc: Seth Jennings <sjenning@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/memory.c | 5 |
1 files changed, 4 insertions, 1 deletions
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, | |||
361 | err: | 361 | err: |
362 | unlock_device_hotplug(); | 362 | unlock_device_hotplug(); |
363 | 363 | ||
364 | if (ret) | 364 | if (ret < 0) |
365 | return ret; | 365 | return ret; |
366 | if (ret) | ||
367 | return -EINVAL; | ||
368 | |||
366 | return count; | 369 | return count; |
367 | } | 370 | } |
368 | 371 | ||