Skip to contentSkip to conversation

mm/memory_hotplug: Do not unlock when fails to take the device_hotplug_lock

PATCH In review zhong jiang 4 participants 4 messages Apr 8, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/memory_hotplug: Do not unlock when fails to take the device_hotplug_lock

When adding the memory by probing memory block in sysfs interface, there is an obvious issue that we will unlock the device_hotplug_lock when fails to takes it.

That issue was introduced in Commit 8df1d0e4a265 ("mm/memory_hotplug: make add_memory() take the device_hotplug_lock")

We should drop out in time when fails to take the device_hotplug_lock.

Fixes 8df1d0e4a265 ("mm/memory_hotplug: make add_memory() take the device_hotplug_lock")
---
 drivers/base/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/memory.c +1 -1
index d9ebb89..0c9e22f 100644
@@ -507,7 +507,7 @@ static ssize_t probe_store(struct device *dev, struct device_attribute *attr,
 
 	ret = lock_device_hotplug_sysfs();
 	if (ret)
-		goto out;
+		return ret;
 
 	nid = memory_add_physaddr_to_nid(phys_addr);
 	ret = __add_memory(nid, phys_addr,
Signature · 1 line
1.7.12.4
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · zhong jiang

When adding the memory by probing memory block in sysfs interface, there is an obvious issue that we will unlock the device_hotplug_lock when fails to takes it.

That issue was introduced in Commit 8df1d0e4a265 ("mm/memory_hotplug: make add_memory() take the device_hotplug_lock")

We should drop out in time when fails to take the device_hotplug_lock.

Fixes 8df1d0e4a265 ("mm/memory_hotplug: make add_memory() take the device_hotplug_lock")
Quoted 20 lines
---
 drivers/base/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/memory.c +1 -1
index d9ebb89..0c9e22f 100644
@@ -507,7 +507,7 @@ static ssize_t probe_store(struct device *dev, struct device_attribute *attr,
 
 	ret = lock_device_hotplug_sysfs();
 	if (ret)
-		goto out;
+		return ret;
 
 	nid = memory_add_physaddr_to_nid(phys_addr);
 	ret = __add_memory(nid, phys_addr,
Signature · 1 line
1.7.12.4
Signature · 2 lines
Michal Hocko
SUSE Labs
Reviewed-by on v1 1/1
#2 lore raw
In reply to zhong jiang
Quoted 21 lines · zhong jiang

When adding the memory by probing memory block in sysfs interface, there is an obvious issue that we will unlock the device_hotplug_lock when fails to takes it.

That issue was introduced in Commit 8df1d0e4a265 ("mm/memory_hotplug: make add_memory() take the device_hotplug_lock")

We should drop out in time when fails to take the device_hotplug_lock.

Fixes 8df1d0e4a265 ("mm/memory_hotplug: make add_memory() take the device_hotplug_lock")
---
 drivers/base/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/memory.c +0 -0
index d9ebb89..0c9e22f 100644

drivers/base/memory.c static ssize_t probe_store(struct device *dev, struct device_attribute *attr, · line 513

Quoted 8 lines
drivers/base/memory.c +1 -1
@@ -507,7 +507,7 @@ static ssize_t probe_store(struct device *dev, struct device_attribute *attr,
 
 	ret = lock_device_hotplug_sysfs();
 	if (ret)
-		goto out;
+		return ret;
 
 	nid = memory_add_physaddr_to_nid(phys_addr);
 	ret = __add_memory(nid, phys_addr,

Indeed

Signature · 3 lines
Thanks,

David / dhildenb
maintainer Reviewed-by on v1 1/1
#3 lore raw
In reply to zhong jiang
Quoted 11 lines · zhong jiang

When adding the memory by probing memory block in sysfs interface, there is an obvious issue that we will unlock the device_hotplug_lock when fails to takes it.

That issue was introduced in Commit 8df1d0e4a265 ("mm/memory_hotplug: make add_memory() take the device_hotplug_lock")

We should drop out in time when fails to take the device_hotplug_lock.

Fixes 8df1d0e4a265 ("mm/memory_hotplug: make add_memory() take the device_hotplug_lock")
Signature · 2 lines
Oscar Salvador
SUSE L3