From: Gabriel Krisman Bertazi <krisman@collabora.com>
To: Emil Velikov <emil.velikov@collabora.com>
Cc: Shreeya Patel <shreeya.patel@collabora.com>,
linus.walleij@linaro.org, brgl@bgdev.pl,
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: Mon, 15 Nov 2021 14:53:49 -0500 [thread overview]
Message-ID: <87tugdxkj6.fsf@collabora.com> (raw)
In-Reply-To: <YYp8JzxfLK2u0fU4@arch-x1c3> (Emil Velikov's message of "Tue, 9 Nov 2021 13:48:23 +0000")
Emil Velikov <emil.velikov@collabora.com> writes:
> 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?
I agree with Emil. The patch seems like a workaround that doesn't
really solve the underlying issue. I'm not familiar with this code, but
it seems that gc is missing a lock during this initialization, to prevent
it from exposing a partially initialized gc->irq.
--
Gabriel Krisman Bertazi
next prev parent reply other threads:[~2021-11-16 0:24 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
2021-11-15 19:53 ` Gabriel Krisman Bertazi [this message]
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=87tugdxkj6.fsf@collabora.com \
--to=krisman@collabora.com \
--cc=brgl@bgdev.pl \
--cc=emil.velikov@collabora.com \
--cc=kernel@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