Re: [PATCH] [sh/highlander] psw: Add error handling in psw_irq_handler

Geert Uytterhoeven <[email protected]>
Newsgroups gmane.linux.ports.sh.devel,gmane.linux.kernel
Message-ID <CAMuHMdVw1oT7L7G5wQUtYK0qAdQ1VayL-DNi=jtGdQ1KER9Ygg@mail.gmail.com>
Hi Haoran,

On Wed, Nov 29, 2023 at 7:38 AM Haoran Liu <[email protected]> wrote:
> This patch adds error handling for the platform_get_drvdata call
> within the psw_irq_handler function in
> arch/sh/boards/mach-highlander/psw.c. Previously, the absence of
> error checking could lead to unexpected behavior if
> platform_get_drvdata returned a null pointer.
>
> Signed-off-by: Haoran Liu <[email protected]>

Thanks for your patch!

> --- a/arch/sh/boards/mach-highlander/psw.c
> +++ b/arch/sh/boards/mach-highlander/psw.c
> @@ -21,6 +21,12 @@ static irqreturn_t psw_irq_handler(int irq, void *arg)
>         unsigned int l, mask;
>         int ret = 0;
>
> +       if (!psw) {
> +               pr_err("psw_irq_handler: No push_switch data associated
> +                       with platform_device\n");
> +               return IRQ_NONE;
> +       }
> +
>         l = __raw_readw(PA_DBSW);
>
>         /* Nothing to do if there's no state change */

This means the button is pressed, and the interrupt fired, in
between the calls to request_irq() and platform_set_drvdata() in
arch/sh/drivers/push-switch.c:switch_drv_probe()?

The same issue can happen with arch/sh/boards/mach-landisk/psw.c.
I think the proper solution is to fix this inside the push switch
driver, by moving the call to request_irq() after the call to
platform_set_drvdata() (and doing the reverse in switch_drv_remove()).

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.