Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1474471

[PATCH v3] memory-hotplug: fix store_mem_state() return value

From Reza Arbab <arbab@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject [PATCH v3] memory-hotplug: fix store_mem_state() return value
Date 2016-09-01 17:30 +0200
Message-ID <scC6e-3Bv-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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 <arbab@linux.vnet.ibm.com>
---
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

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH v3] memory-hotplug: fix store_mem_state() return value Reza Arbab <arbab@linux.vnet.ibm.com> - 2016-09-01 17:30 +0200
  Re: [PATCH v3] memory-hotplug: fix store_mem_state() return value Andrew Morton <akpm@linux-foundation.org> - 2016-09-01 23:00 +0200
    Re: [PATCH v3] memory-hotplug: fix store_mem_state() return value Reza Arbab <arbab@linux.vnet.ibm.com> - 2016-09-01 23:50 +0200
    Re: [PATCH v3] memory-hotplug: fix store_mem_state() return value Xishi Qiu <qiuxishi@huawei.com> - 2016-09-02 03:40 +0200

csiph-web