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

From: Linus Walleij

Date: Mon May 25 2026 - 04:12:05 EST


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.

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

Yours,
Linus Walleij