[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YYp8JzxfLK2u0fU4@arch-x1c3>
Date: Tue, 9 Nov 2021 13:48:23 +0000
From: Emil Velikov <emil.velikov@...labora.com>
To: Shreeya Patel <shreeya.patel@...labora.com>
Cc: linus.walleij@...aro.org, brgl@...ev.pl, krisman@...labora.com,
linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
kernel@...labora.com
Subject: Re: [PATCH] gpio: Initialize gc->irq.domain before setting gc->to_irq
Hi Shreeya, all,
On 2021/11/09, Shreeya Patel wrote:
> There is a race in registering of gc->irq.domain when
> probing the I2C driver.
> This sometimes leads to a Kernel NULL pointer dereference
> in gpiochip_to_irq function which uses the domain variable.
>
> To avoid this issue, set gc->to_irq after domain is
> initialized. This will make sure whenever gpiochip_to_irq
> is called, it has domain already initialized.
>
What is stopping the next developer to moving the assignment to the
incorrect place? Aka should we add an inline comment about this?
<snip>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index abfbf546d159..9a6f7c265a91 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -1512,7 +1512,6 @@ static int gpiochip_add_irqchip(struct gpio_chip *gc,
> if (gc->to_irq)
> chip_warn(gc, "to_irq is redefined in %s and you shouldn't rely on it\n", __func__);
>
Move the warning alongside the assignment?
HTH
Emil
Powered by blists - more mailing lists