mm/memory_hotplug: Drop memory device reference after find_memory_block()
Subsystems (2)
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().
--- mm/memory_hotplug.c | 1 + 1 file changed, 1 insertion(+)
mm/memory_hotplug.c +1 -0
@@ -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
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 viadevice_unregister(), resulting in no user visible problem, the device is never released viadevice_release(), resulting in a memory leak. Fix that by properly using aput_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]>Reviewed-by Oscar Salvador <[email protected]>Reviewed-by Wei Yang <[email protected]>Acked-by Michal Hocko <[email protected]>Signed-off-by David Hildenbrand <[email protected]>--- mm/memory_hotplug.c | 1 + 1 file changed, 1 insertion(+)mm/memory_hotplug.c +0
-0@@ -854,6 +854,7 @@ int __ref online_pages(unsigned long pfn, unsigned long
nr_pages, intonline_typmm/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.