linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] mm/memory_hotplug: fix error return code in add_memory_resource()
@ 2023-08-09  8:15 Yang Yingliang
  2023-08-09  8:39 ` David Hildenbrand
  2023-08-09  9:19 ` Aneesh Kumar K.V
  0 siblings, 2 replies; 3+ messages in thread
From: Yang Yingliang @ 2023-08-09  8:15 UTC (permalink / raw)
  To: linux-mm; +Cc: david, osalvador, akpm, mhocko, aneesh.kumar, yangyingliang

Set error return code to -ENOMEM, when kmalloc() fails.

Fixes: ad3232df3e41 ("mm/memory_hotplug: embed vmem_altmap details in memory block")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 mm/memory_hotplug.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index f8d3e7427e32..1b03f4ec6fd2 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1440,8 +1440,10 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags)
 		if (mhp_supports_memmap_on_memory(size)) {
 			mhp_altmap.free = memory_block_memmap_on_memory_pages();
 			params.altmap = kmalloc(sizeof(struct vmem_altmap), GFP_KERNEL);
-			if (!params.altmap)
+			if (!params.altmap) {
+				ret = -ENOMEM;
 				goto error;
+			}
 
 			memcpy(params.altmap, &mhp_altmap, sizeof(mhp_altmap));
 		}
-- 
2.25.1



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-09  9:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-09  8:15 [PATCH -next] mm/memory_hotplug: fix error return code in add_memory_resource() Yang Yingliang
2023-08-09  8:39 ` David Hildenbrand
2023-08-09  9:19 ` Aneesh Kumar K.V

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox