[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdVw1oT7L7G5wQUtYK0qAdQ1VayL-DNi=jtGdQ1KER9Ygg@mail.gmail.com>
Date: Wed, 29 Nov 2023 09:10:41 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Haoran Liu <liuhaoran14@....com>
Cc: ysato@...rs.sourceforge.jp, dalias@...c.org,
glaubitz@...sik.fu-berlin.de, linux-sh@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] [sh/highlander] psw: Add error handling in psw_irq_handler
Hi Haoran,
On Wed, Nov 29, 2023 at 7:38 AM Haoran Liu <liuhaoran14@....com> 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 <liuhaoran14@....com>
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 -- geert@...ux-m68k.org
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
Powered by blists - more mailing lists