On Fri, Jul 11, 2025 at 04:29:48PM +0200, Daniel Gomez wrote:
> On 09/07/2025 15.49, Mike Rapoport wrote:
> > From: "Mike Rapoport (Microsoft)" <r...@kernel.org>
> > 
> > Some callers of execmem_alloc() require the memory to be temporarily
> > writable even when it is allocated from ROX cache. These callers use
> > execemem_make_temp_rw() right after the call to execmem_alloc().
> > 
> > Wrap this sequence in execmem_alloc_rw() API.
> > 
> > Signed-off-by: Mike Rapoport (Microsoft) <r...@kernel.org>
> 
> Reviewed-by: Daniel Gomez <da.go...@samsung.com>
> 
> > ---
> > diff --git a/mm/execmem.c b/mm/execmem.c
> > index 0712ebb4eb77..6b040fbc5f4f 100644
> > --- a/mm/execmem.c
> > +++ b/mm/execmem.c
> 
> {...}
> 
> > @@ -387,6 +397,21 @@ void *execmem_alloc(enum execmem_type type, size_t 
> > size)
> >     return kasan_reset_tag(p);
> >  }
> >  
> > +void *execmem_alloc_rw(enum execmem_type type, size_t size)
> > +{
> > +   void *p __free(execmem) = execmem_alloc(type, size);
> > +   int err;
> > +
> > +   if (!p)
> > +           return NULL;
> > +
> > +   err = execmem_force_rw(p, size);
> > +   if (err)
> > +           return NULL;
> 
> You don't need to save the error here. That, allows err declaration to be
> dropped.

I prefer to keep err = ... It's more explicit and clear this way.

-- 
Sincerely yours,
Mike.

Reply via email to