Thread (3 messages) flat view 3 messages, 3 authors, 2021-11-26

Re: [PATCH] gpio: Initialize gc->irq.domain before setting gc->to_irq

From: Gabriel Krisman Bertazi <hidden>
Date: 2021-11-16 00:24:33
Also in: lkml

Emil Velikov [off-list ref] writes:
Hi Shreeya, all,

On 2021/11/09, Shreeya Patel wrote:
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help