Commit a37f8630 authored by Yasuaki Ishimatsu's avatar Yasuaki Ishimatsu Committed by Greg Kroah-Hartman

driver core: Release device_hotplug_lock when store_mem_state returns EINVAL

When inserting a wrong value to /sys/devices/system/memory/memoryX/state file,
following messages are shown. And device_hotplug_lock is never released.

================================================
[ BUG: lock held when returning to user space! ]
3.12.0-rc4-debug+ #3 Tainted: G        W
------------------------------------------------
bash/6442 is leaving the kernel with locks still held!
1 lock held by bash/6442:
 #0:  (device_hotplug_lock){+.+.+.}, at: [<ffffffff8146cbb5>] lock_device_hotplug_sysfs+0x15/0x50

This issue was introdued by commit fa2be40f (drivers: base: use standard
device online/offline for state change).

This patch releases device_hotplug_lcok when store_mem_state returns EINVAL.
Signed-off-by: default avatarYasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
Reviewed-by: default avatarToshi Kani <toshi.kani@hp.com>
CC: Seth Jennings <sjenning@linux.vnet.ibm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 15c03dd4
...@@ -333,8 +333,10 @@ store_mem_state(struct device *dev, ...@@ -333,8 +333,10 @@ store_mem_state(struct device *dev,
online_type = ONLINE_KEEP; online_type = ONLINE_KEEP;
else if (!strncmp(buf, "offline", min_t(int, count, 7))) else if (!strncmp(buf, "offline", min_t(int, count, 7)))
online_type = -1; online_type = -1;
else else {
return -EINVAL; ret = -EINVAL;
goto err;
}
switch (online_type) { switch (online_type) {
case ONLINE_KERNEL: case ONLINE_KERNEL:
...@@ -357,6 +359,7 @@ store_mem_state(struct device *dev, ...@@ -357,6 +359,7 @@ store_mem_state(struct device *dev,
ret = -EINVAL; /* should never happen */ ret = -EINVAL; /* should never happen */
} }
err:
unlock_device_hotplug(); unlock_device_hotplug();
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment