linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] memory-hotplug: fix store_mem_state() return value
@ 2016-09-01 15:29 Reza Arbab
  2016-09-01 20:37 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Reza Arbab @ 2016-09-01 15:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Andrew Morton, Vlastimil Babka,
	Vitaly Kuznetsov, David Rientjes, Yaowei Bai, Joonsoo Kim,
	Dan Williams, Xishi Qiu, David Vrabel, Chen Yucong,
	Andrew Banman, Seth Jennings, linux-mm, linux-kernel

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

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-09-02  1:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-01 15:29 [PATCH v3] memory-hotplug: fix store_mem_state() return value Reza Arbab
2016-09-01 20:37 ` Andrew Morton
2016-09-01 21:45   ` Reza Arbab
2016-09-02  1:34   ` Xishi Qiu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox