From: "Ze Huang" <huang.ze@linux.dev>
To: "Linus Walleij" <linusw@kernel.org>,
"Jiayu Du" <jiayu.riscv@isrc.iscas.ac.cn>
Cc: <pjw@kernel.org>, <palmer@dabbelt.com>, <aou@eecs.berkeley.edu>,
<alex@ghiti.fr>, <linux-gpio@vger.kernel.org>,
<linux-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
<gaohan@iscas.ac.cn>, <me@ziyao.cc>
Subject: Re: [PATCH v2] pinctrl: canaan: k230: Fix NULL pointer dereference when parsing devicetree
Date: Tue, 03 Feb 2026 22:02:33 +0800 [thread overview]
Message-ID: <DG5DRZU7IUOE.38JEHK3H9ICCV@linux.dev> (raw)
In-Reply-To: <CAD++jL=Up=y_pX4Xy50in08cT978ANaoiD_98nn99frb8=5vOA@mail.gmail.com>
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@isrc.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@isrc.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
WARNING: multiple messages have this Message-ID (diff)
From: "Ze Huang" <huang.ze@linux.dev>
To: "Linus Walleij" <linusw@kernel.org>,
"Jiayu Du" <jiayu.riscv@isrc.iscas.ac.cn>
Cc: <pjw@kernel.org>, <palmer@dabbelt.com>, <aou@eecs.berkeley.edu>,
<alex@ghiti.fr>, <linux-gpio@vger.kernel.org>,
<linux-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
<gaohan@iscas.ac.cn>, <me@ziyao.cc>
Subject: Re: [PATCH v2] pinctrl: canaan: k230: Fix NULL pointer dereference when parsing devicetree
Date: Tue, 03 Feb 2026 22:02:33 +0800 [thread overview]
Message-ID: <DG5DRZU7IUOE.38JEHK3H9ICCV@linux.dev> (raw)
In-Reply-To: <CAD++jL=Up=y_pX4Xy50in08cT978ANaoiD_98nn99frb8=5vOA@mail.gmail.com>
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@isrc.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@isrc.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
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-02-03 14:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-28 15:49 [PATCH v2] pinctrl: canaan: k230: Fix NULL pointer dereference when parsing devicetree Jiayu Du
2025-12-28 15:49 ` Jiayu Du
2026-01-15 6:38 ` Jiayu Du
2026-01-15 6:38 ` Jiayu Du
2026-01-20 6:03 ` Jiayu Du
2026-01-20 6:03 ` Jiayu Du
2026-02-03 0:32 ` Linus Walleij
2026-02-03 0:32 ` Linus Walleij
2026-02-03 14:02 ` Ze Huang [this message]
2026-02-03 14:02 ` Ze Huang
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=DG5DRZU7IUOE.38JEHK3H9ICCV@linux.dev \
--to=huang.ze@linux.dev \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=gaohan@iscas.ac.cn \
--cc=jiayu.riscv@isrc.iscas.ac.cn \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=me@ziyao.cc \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.