This Linux kernel change "mm/memory_hotplug.c: drop memory device reference after find_memory_block()" is included in the Linux 5.1 release. This change is authored by David Hildenbrand <david [at] redhat.com> on Thu Apr 25 22:23:37 2019 -0700. The commit for this change in Linux stable tree is 89c02e6 (patch).
mm/memory_hotplug.c: 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(). Link: http://email@example.com Fixes: d0dc12e86b31 ("mm/memory_hotplug: optimize memory hotplug") Signed-off-by: David Hildenbrand <firstname.lastname@example.org> Reviewed-by: Oscar Salvador <email@example.com> Reviewed-by: Wei Yang <firstname.lastname@example.org> Acked-by: Michal Hocko <email@example.com> Acked-by: Pankaj Gupta <firstname.lastname@example.org> Cc: David Hildenbrand <email@example.com> Cc: Pavel Tatashin <firstname.lastname@example.org> Cc: Qian Cai <email@example.com> Cc: Arun KS <firstname.lastname@example.org> Cc: Mathieu Malaterre <email@example.com> Signed-off-by: Andrew Morton <firstname.lastname@example.org> Signed-off-by: Linus Torvalds <email@example.com>
There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.
mm/memory_hotplug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 0082d69..b236069 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -874,6 +874,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);