[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DG5DRZU7IUOE.38JEHK3H9ICCV@linux.dev>
Date: Tue, 03 Feb 2026 22:02:33 +0800
From: "Ze Huang" <huang.ze@...ux.dev>
To: "Linus Walleij" <linusw@...nel.org>, "Jiayu Du"
<jiayu.riscv@...c.iscas.ac.cn>
Cc: <pjw@...nel.org>, <palmer@...belt.com>, <aou@...s.berkeley.edu>,
<alex@...ti.fr>, <linux-gpio@...r.kernel.org>,
<linux-riscv@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
<gaohan@...as.ac.cn>, <me@...ao.cc>
Subject: Re: [PATCH v2] pinctrl: canaan: k230: Fix NULL pointer dereference
when parsing devicetree
On Tue Feb 3, 2026 at 8:32 AM CST, Linus Walleij wrote:
> On Sun, Dec 28, 2025 at 4:53 PM Jiayu Du <jiayu.riscv@...c.iscas.ac.cn> wrote:
>
>> When probing the k230 pinctrl driver, the kernel triggers a NULL pointer
>> dereference. The crash trace showed:
>> [ 0.732084] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000068
>> [ 0.740737] ...
>> [ 0.776296] epc : k230_pinctrl_probe+0x1be/0x4fc
>>
>> In k230_pinctrl_parse_functions(), we attempt to retrieve the device
>> pointer via info->pctl_dev->dev, but info->pctl_dev is only initialized
>> after k230_pinctrl_parse_dt() completes.
>>
>> At the time of DT parsing, info->pctl_dev is still NULL, leading to
>> the invalid dereference of info->pctl_dev->dev.
>>
>> Use the already available device pointer from platform_device
>> instead of accessing through uninitialized pctl_dev.
>>
>> Fixes: d94a32ac688f ("pinctrl: canaan: k230: Fix order of DT parse and pinctrl register")
>> Signed-off-by: Jiayu Du <jiayu.riscv@...c.iscas.ac.cn>
>
> Patch applied!
>
> Sorry for missing this, I was waiting for maintainer feedback
> but it never arrived.
>
> Yours,
> Linus Walleij
Hi Linus, Jiayu,
Apologies for the delay.
I tested this on k230; it fixes the NULL pointer dereference during pinctrl
probing. The approach is correct.
Thanks to you both!
Best regards, Ze Huang
Powered by blists - more mailing lists