Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Emil Velikov <emil.velikov@collabora.com>
To: Shreeya Patel <shreeya.patel@collabora.com>
Cc: linus.walleij@linaro.org, brgl@bgdev.pl, krisman@collabora.com,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@collabora.com
Subject: Re: [PATCH] gpio: Initialize gc->irq.domain before setting gc->to_irq
Date: Tue, 9 Nov 2021 13:48:23 +0000	[thread overview]
Message-ID: <YYp8JzxfLK2u0fU4@arch-x1c3> (raw)
In-Reply-To: <20211108214148.9724-1-shreeya.patel@collabora.com>

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

  reply	other threads:[~2021-11-09 13:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-08 21:41 [PATCH] gpio: Initialize gc->irq.domain before setting gc->to_irq Shreeya Patel
2021-11-09 13:48 ` Emil Velikov [this message]
2021-11-15 19:53   ` Gabriel Krisman Bertazi
2021-11-25 10:56     ` Shreeya Patel
2021-11-26  1:17       ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YYp8JzxfLK2u0fU4@arch-x1c3 \
    --to=emil.velikov@collabora.com \
    --cc=brgl@bgdev.pl \
    --cc=kernel@collabora.com \
    --cc=krisman@collabora.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shreeya.patel@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox