From: "Gary Guo" <gary@garyguo.net>
To: "Andrea della Porta" <andrea.porta@suse.com>,
<sashiko-reviews@lists.linux.dev>
Cc: <devicetree@vger.kernel.org>, <conor+dt@kernel.org>,
<robh@kernel.org>, <ukleinek@kernel.org>
Subject: Re: [PATCH v7 2/3] pwm: rp1: Add RP1 PWM controller driver
Date: Tue, 25 Aug 2026 19:42:19 +0100 [thread overview]
Message-ID: <DKY8USKYJJVM.17HQ78YIYZMFV@garyguo.net> (raw)
In-Reply-To: <amN-5B5POX3rNb29@apocalypse>
On Fri Jul 24, 2026 at 4:04 PM BST, Andrea della Porta wrote:
> Hi,
>
> On 10:02 Mon 20 Jul , sashiko-bot@kernel.org wrote:
>> Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
>> - [High] Missing `.remove` callback leads to Use-After-Free in the PWM and Syscon cores and leaks clock resources on driver unbind.
>> - [High] Register context loss on suspend/resume silently breaks PWM output.
>> - [High] Unclamped hardware duty ticks lead to integer underflow in the PWM core for normal polarity.
>> --
>>
>> --- Patch [2]: [PATCH v7 2/3] pwm: rp1: Add RP1 PWM controller driver ---
>> commit 0c98703d857577902e57d25b42a3d46dfbde5795
>> Author: Naushir Patuck <naush@raspberrypi.com>
>>
>> pwm: rp1: Add RP1 PWM controller driver
>>
>> The Raspberry Pi RP1 southbridge features an embedded PWM controller with
>> 4 output channels, alongside an RPM interface to read the fan speed on the
>> Raspberry Pi 5. Add the supporting driver.
>
>> > +static struct platform_driver rp1_pwm_driver = {
>> > + .probe = rp1_pwm_probe,
>> > + /*
>> > + * .remove is not needed because this driver cannot be removed/unbound
>> > + * cause it relies on syscon which cannot be removed
>> > + */
>> > + .driver = {
>> > + .name = "rp1-pwm",
>>
>> [Severity: High]
>> Is it safe to omit the remove callback here?
>>
>> Even with suppress_bind_attrs set on the driver, if the parent RP1 PCIe
>> device is removed, reset, or unbound via sysfs, it will forcibly unbind all
>> child devices.
>>
>> Without a remove callback to run cleanup, pwmchip_remove() is never called
>> and the clock is left enabled. Because the backing memory is devm-managed,
>> the devres subsystem will eventually free the pwm_chip and regmap memory.
>> This can leave dangling pointers in the core pwm_chips IDR and the global
>> syscon_list, which could result in a use-after-free.
>
> This is true. Uwe, I guess I should reintroduce the .remove callback,
> what do you think?
>
How is remove going to work with syscon? The previous version seems to just
ignore it completely.
Also, do you actually need syscon here? Given that the pwm fan device is going
to depend on the PWM fan device anyway, you could just EXPORT_SYMBOL_NS an API
from the rp1 driver that returns the tachometer reading when supplied with a rp1
pwm device pointer?
Best,
Gary
next prev parent reply other threads:[~2026-08-25 18:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 9:44 [PATCH v7 0/3] Add RP1 PWM controller support Andrea della Porta
2026-07-20 9:44 ` [PATCH v7 1/3] dt-bindings: pwm: Add Raspberry Pi RP1 PWM controller Andrea della Porta
2026-07-20 9:50 ` sashiko-bot
2026-07-24 14:16 ` Andrea della Porta
2026-07-20 9:44 ` [PATCH v7 2/3] pwm: rp1: Add RP1 PWM controller driver Andrea della Porta
2026-07-20 10:02 ` sashiko-bot
2026-07-24 15:04 ` Andrea della Porta
2026-08-25 18:42 ` Gary Guo [this message]
2026-09-04 13:53 ` Andrea della Porta
2026-09-04 14:05 ` Gary Guo
2026-09-04 16:42 ` Andrea della Porta
2026-09-03 20:36 ` Christophe JAILLET
2026-09-04 16:31 ` Andrea della Porta
2026-07-20 9:44 ` [PATCH v7 3/3] arm64: dts: broadcom: rpi-5: Add RP1 PWM node Andrea della Porta
2026-09-03 20:11 ` [PATCH v7 0/3] Add RP1 PWM controller support Florian Fainelli
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=DKY8USKYJJVM.17HQ78YIYZMFV@garyguo.net \
--to=gary@garyguo.net \
--cc=andrea.porta@suse.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=ukleinek@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox