Re: [PATCH v2 1/2] mm/memblock: Add "reserve_mem" to reserved named memory at boot up

From: Steven Rostedt
Date: Tue Jun 11 2024 - 15:39:11 EST


On Tue, 11 Jun 2024 11:12:18 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> > >+ p++;
> > >+ err = reserved_mem_add(start, size, p);
> > >+ if (err) {
> > >+ memblock_phys_free(start, size);
> > >+ return err;
> > >+ }
> > >+
> > >+ p += strlen(p);
> > >+
> > >+ return *p == '\0' ? 0: -EINVAL;
> >
> > We won't free the memory if return -EINVAL?

I actually copied this from parse_memmap_one() in arch/x86/kernel/e820.c
and now looking at it, it's a pretty stupid check.

It does: p += strlen(p); which requires p ending with '\0'. So this will
likely bug if there is no '\0'.

I'm going to remove this, but still check to make sure that the name has
some length before the allocation.

-- Steve