From 18e98e56f4407b8c766b6f6d9f2850fd2a081e4d Mon Sep 17 00:00:00 2001 From: Barry Song Date: Tue, 11 Aug 2020 18:31:57 -0700 Subject: mm: cma: fix the name of CMA areas Patch series "mm: fix the names of general cma and hugetlb cma", v2. The current code of CMA can only work when users pass a const string as name parameter. we need to fix the way to handle names in CMA. On the other hand, to avoid name conflicts after enabling CMA_DEBUGFS, each hugetlb should get a different CMA name. This patch (of 2): If users give a name saved in stack, the current code will generate magic pointer. if users don't give a name(NULL), kasprintf() will always return NULL as we are at the early stage. that means cma_init_reserved_mem() will return -ENOMEM if users set name parameter as NULL. [natechancellor@gmail.com: return cma->name directly in cma_get_name] Link: https://github.com/ClangBuiltLinux/linux/issues/1063 Link: http://lkml.kernel.org/r/20200623015840.621964-1-natechancellor@gmail.com Signed-off-by: Barry Song Signed-off-by: Nathan Chancellor Signed-off-by: Andrew Morton Reviewed-by: Mike Kravetz Acked-by: Roman Gushchin Link: http://lkml.kernel.org/r/20200616223131.33828-2-song.bao.hua@hisilicon.com Signed-off-by: Linus Torvalds --- mm/cma.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mm/cma.h') diff --git a/mm/cma.h b/mm/cma.h index 6698fa63279b..20f6e24bc477 100644 --- a/mm/cma.h +++ b/mm/cma.h @@ -4,6 +4,8 @@ #include +#define CMA_MAX_NAME 64 + struct cma { unsigned long base_pfn; unsigned long count; @@ -15,7 +17,7 @@ struct cma { spinlock_t mem_head_lock; struct debugfs_u32_array dfs_bitmap; #endif - const char *name; + char name[CMA_MAX_NAME]; }; extern struct cma cma_areas[MAX_CMA_AREAS]; -- cgit v1.2.3