From 7699f162e1a57de350928d5ce3e3c71774c7d4f3 Mon Sep 17 00:00:00 2001 From: David Hildenbrand Date: Tue, 7 May 2019 10:37:12 +0800 Subject: [PATCH] mm/memory_hotplug.c: drop memory device reference after find_memory_block() mainline inclusion from mainline-v5.1-rc6 commit 89c02e69fc52 category: bugfix bugzilla: 14244 CVE: NA ------------------------------------------------- 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://lkml.kernel.org/r/20190411110955.1430-1-david@redhat.com Fixes: d0dc12e86b31 ("mm/memory_hotplug: optimize memory hotplug") Signed-off-by: David Hildenbrand Reviewed-by: Oscar Salvador Reviewed-by: Wei Yang Acked-by: Michal Hocko Acked-by: Pankaj Gupta Cc: David Hildenbrand Cc: Pavel Tatashin Cc: Qian Cai Cc: Arun KS Cc: Mathieu Malaterre Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Reviewed-by: Jing Xiangfeng Signed-off-by: zhong jiang Signed-off-by: Yang Yingliang --- mm/memory_hotplug.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 9e24e11c88a8..7546d90c6ed3 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -902,6 +902,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); -- GitLab