Skip to contentSkip to conversation

mm/cma: fix stray newline in auto-generated CMA area name

PATCH In review Ivy Lopez 2 participants 2 messages Aug 11

Subsystems (2)
lore
Share & tools
lore

Ivy Lopez

author
#0 lore raw

PATCH 1/1 mm/cma: fix stray newline in auto-generated CMA area name

When no explicit name is provided, cma_new_area() falls back to generating one via snprintf(), but the format string contains an embedded newline: "cma%d\n". This name is used as-is for the area's sysfs entry (cma_sysfs.c) and debugfs directory (cma_debug.c), so every auto-named CMA area ends up with a newline embedded in its sysfs/debugfs name.

Drop the stray newline and the extra space after the size argument.

---
 mm/cma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/cma.c +1 -1
index a13ce4999b39..092cbb8f27ec 100644
@@ -240,7 +240,7 @@ static int __init cma_new_area(const char *name, phys_addr_t size,
 	if (name)
 		strscpy(cma->name, name);
 	else
-		snprintf(cma->name, CMA_MAX_NAME,  "cma%d\n", cma_area_count);
+		snprintf(cma->name, CMA_MAX_NAME, "cma%d", cma_area_count);
 
 	cma->available_count = cma->count = size >> PAGE_SHIFT;
 	cma->order_per_bit = order_per_bit;
Signature · 1 line
2.55.0
#1 lore raw
Quoted 19 lines · Ivy Lopez

When no explicit name is provided, cma_new_area() falls back to generating one via snprintf(), but the format string contains an embedded newline: "cma%d\n". This name is used as-is for the area's sysfs entry (cma_sysfs.c) and debugfs directory (cma_debug.c), so every auto-named CMA area ends up with a newline embedded in its sysfs/debugfs name.

Drop the stray newline and the extra space after the size argument.

---
 mm/cma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/cma.c +0 -0
index a13ce4999b39..092cbb8f27ec 100644

mm/cma.c static int __init cma_new_area(const char *name, phys_addr_t size, · line 246

Quoted 8 lines
mm/cma.c +1 -1
@@ -240,7 +240,7 @@ static int __init cma_new_area(const char *name, phys_addr_t size,
 	if (name)
 		strscpy(cma->name, name);
 	else
-		snprintf(cma->name, CMA_MAX_NAME,  "cma%d\n", cma_area_count);
+		snprintf(cma->name, CMA_MAX_NAME, "cma%d", cma_area_count);
 
 	cma->available_count = cma->count = size >> PAGE_SHIFT;
 	cma->order_per_bit = order_per_bit;

Hi,

please see

https://lore.kernel.org/r/[email protected]

Signature · 3 lines
Cheers,

David