Re: [PATCH v2 2/8] execmem: introduce execmem_alloc_rw()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)" <rppt@xxxxxxxxxx>
> > 
> > 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) <rppt@xxxxxxxxxx>
> 
> Reviewed-by: Daniel Gomez <da.gomez@xxxxxxxxxxx>
> 
> > ---
> > 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.




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux