Re: [PATCH] mm/cma: Replace snprintf with strscpy in cma_new_area

From: Andrew Morton

Date: Mon Jan 26 2026 - 19:55:00 EST


On Mon, 26 Jan 2026 16:47:22 -0800 SeongJae Park <sj@xxxxxxxxxx> wrote:

> > @@ -233,7 +234,7 @@ static int __init cma_new_area(const char *name, phys_addr_t size,
> > cma_area_count++;
> >
> > if (name)
> > - snprintf(cma->name, CMA_MAX_NAME, "%s", name);
> > + strscpy(cma->name, name);
>
> Any reason to drop CMA_MAX_NAME protection? You can pass the size of
> destination buffer as the third argument of strscpy().

strscpy() will now use sizeof(cma->name):

char name[CMA_MAX_NAME];