Skip to contentSkip to conversation

mm/memory_hotplug: Drop memory device reference after find_memory_block()

PATCH In review David Hildenbrand 2 participants 2 messages Apr 11, 2019

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

PATCH v2 1/1 mm/memory_hotplug: Drop memory device reference after find_memory_block()

Right now we are using find_memory_block() to get the node id for the pfn range to online. We are missing to drop a reference to the memory block device. While the device still gets unregistered via device_unregister(), resulting in no user visible problem, the device is never released via device_release(), resulting in a memory leak. Fix that by properly using a put_device().

Fixes d0dc12e86b31 ("mm/memory_hotplug: optimize memory hotplug")
Cc Andrew Morton <[email protected]>
Cc Oscar Salvador <[email protected]>
Cc Michal Hocko <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Pavel Tatashin <[email protected]>
Cc Wei Yang <[email protected]>
Cc Qian Cai <[email protected]>
Cc Arun KS <[email protected]>
Cc Mathieu Malaterre <[email protected]>
---
 mm/memory_hotplug.c | 1 +
 1 file changed, 1 insertion(+)
mm/memory_hotplug.c +1 -0
index 5eb4a4c7c21b..328878b6799d 100644
@@ -854,6 +854,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, int online_typ
 	 */
 	mem = find_memory_block(__pfn_to_section(pfn));
 	nid = mem->nid;
+	put_device(&mem->dev);
 
 	/* associate pfn range with the zone */
 	zone = move_pfn_range(online_type, nid, pfn, nr_pages);
Signature · 1 line
2.20.1
Acked-by on v2 1/1
#1 lore raw
Quoted 40 lines

Right now we are using find_memory_block() to get the node id for the pfn range to online. We are missing to drop a reference to the memory block device. While the device still gets unregistered via device_unregister(), resulting in no user visible problem, the device is never released via device_release(), resulting in a memory leak. Fix that by properly using a put_device().

Fixes d0dc12e86b31 ("mm/memory_hotplug: optimize memory hotplug")
Cc Andrew Morton <[email protected]>
Cc Oscar Salvador <[email protected]>
Cc Michal Hocko <[email protected]>
Cc David Hildenbrand <[email protected]>
Cc Pavel Tatashin <[email protected]>
Cc Wei Yang <[email protected]>
Cc Qian Cai <[email protected]>
Cc Arun KS <[email protected]>
Cc Mathieu Malaterre <[email protected]>
---
 mm/memory_hotplug.c | 1 +
 1 file changed, 1 insertion(+)
mm/memory_hotplug.c +0 -0
index 5eb4a4c7c21b..328878b6799d 100644
@@ -854,6 +854,7 @@ int __ref online_pages(unsigned long pfn, unsigned long

nr_pages, int online_typ

mm/memory_hotplug.c +1 -1
 	 */
 	mem = find_memory_block(__pfn_to_section(pfn));
 	nid = mem->nid;
+	put_device(&mem->dev);
 
 	/* associate pfn range with the zone */
 	zone = move_pfn_range(online_type, nid, pfn, nr_pages);
--
Quoted 1 line

2.20.1

Good catch it is.

Quoted 2 lines