Re: [PATCH] gpiolib: Mark gpio_devt, gpiolib_initialized and gpio_stub_drv as __ro_after_init

From: Len Bao

Date: Sat May 30 2026 - 06:09:04 EST


Hi Linus,

On Mon, May 25, 2026 at 10:10:02AM +0200, Linus Walleij wrote:
> Hi Len,
>
> thanks for your patch!
>
> On Sat, May 16, 2026 at 12:58 PM Len Bao <len.bao@xxxxxx> wrote:
>
> > The 'gpio_devt' and 'gpiolib_initialized' variables are initialized only
> > during the init phase in the 'gpiolib_dev_init' function and never
> > changed. So, mark these as __ro_after_init.
> >
> > The 'gpio_stub_drv' variable is initialized only in the declaration and
> > never changed. So, this variable could be 'const', but using the
> > 'driver_register' and 'driver_unregister' functions discards the 'const'
> > qualifier. Therefore, as an alternative, mark it as a __ro_after_init.
> >
> > Signed-off-by: Len Bao <len.bao@xxxxxx>
>
> Patches like this should be CC to linux-hardening.

Ok, next time I will CC to linux-hardening. Thanks for the guidance.

> Anyways it looks good to me!
> Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>

Thanks for your time to look at this.

Regards,
Len Bao

> Yours,
> Linus Walleij