Skip to contentSkip to conversation

mm/memory_hotplug: fix error return code in add_memory_resource()

PATCH In review Yang Yingliang 3 participants 3 messages Aug 9, 2023

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

PATCH 1/1 mm/memory_hotplug: fix error return code in add_memory_resource()

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

Fixes ad3232df3e41 ("mm/memory_hotplug: embed vmem_altmap details in memory block")
---
 mm/memory_hotplug.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
mm/memory_hotplug.c +3 -1
index f8d3e7427e32..1b03f4ec6fd2 100644
@@ -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));
 		}
Signature · 1 line
2.25.1
#1 lore raw
Quoted 3 lines · Yang Yingliang

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

Fixes ad3232df3e41 ("mm/memory_hotplug: embed vmem_altmap details in memory block")

Commit id is not stable yet.

Quoted 10 lines
---
  mm/memory_hotplug.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
mm/memory_hotplug.c +0 -0
index f8d3e7427e32..1b03f4ec6fd2 100644

mm/memory_hotplug.c int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) · line 1446

Quoted 8 lines
mm/memory_hotplug.c +3 -1
@@ -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;
+			}

LGTM, should be squashed into the original commit.

Thanks!

Signature · 3 lines
Cheers,

David / dhildenb
Reviewed-by on v1 1/1
#2 lore raw
In reply to Yang Yingliang
Quoted 4 lines · Yang Yingliang

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

Fixes ad3232df3e41 ("mm/memory_hotplug: embed vmem_altmap details in memory block")
Quoted 22 lines
---
 mm/memory_hotplug.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
mm/memory_hotplug.c +3 -1
index f8d3e7427e32..1b03f4ec6fd2 100644
@@ -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));
 		}
Signature · 1 line
2.25.1