[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1472743777-24266-1-git-send-email-arbab@linux.vnet.ibm.com>
Date: Thu, 1 Sep 2016 10:29:37 -0500
From: Reza Arbab <arbab@...ux.vnet.ibm.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Vlastimil Babka <vbabka@...e.cz>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
David Rientjes <rientjes@...gle.com>,
Yaowei Bai <baiyaowei@...s.chinamobile.com>,
Joonsoo Kim <iamjoonsoo.kim@....com>,
Dan Williams <dan.j.williams@...el.com>,
Xishi Qiu <qiuxishi@...wei.com>,
David Vrabel <david.vrabel@...rix.com>,
Chen Yucong <slaoub@...il.com>,
Andrew Banman <abanman@....com>,
Seth Jennings <sjenning@...hat.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v3] 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.
Signed-off-by: Reza Arbab <arbab@...ux.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
Powered by blists - more mailing lists