Devicetree
 help / color / mirror / Atom feed
From: Alex Elder <elder@riscstar.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v5 4/4] arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node
Date: Thu, 3 Dec 2026 20:43:02 -0600	[thread overview]
Message-ID: <94d0865f-df47-463a-9f41-9acc07d4e9a6@riscstar.com> (raw)
In-Reply-To: <sashiko-outbox-248633@kernel.org>

On 12/3/26 2:28 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issues to consider:
> - [High] arm64: dts: qcom: BAR4 translation fails for TC9564
>    clock-controller@1004
> - [Medium] clk: toshiba: devm_reset_register() frees aux_data before
>    auxdev destroy
> - [Medium] clk: toshiba: devm_reset_register() leaks aux_data on
>    ida_alloc() failure
> --
> 
> commit 179c9f9b50bcdb23af6216cf3aeac69795b3017e
> Author: Alex Elder <elder@kernel.org>
> 
> arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node
> 
> This commit adds a fixed 25 MHz crystal clock node and a TC9564 clock and
> reset controller node under pci-ep-bus@4 in the QCS6490 RB3Gen2 device tree.
> 
>> diff --git a/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts b/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts
>> index 682bcbc0b466b..87035745b6720 100644
>> --- a/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts
>> +++ b/arch/arm64/boot/dts/qcom/qcs6490-rb3gen2.dts
> 
> [ ... ]
> 
>> @@ -969,6 +976,14 @@ pci-ep-bus@4 {
>>   					#size-cells = <1>;
>>   					/* Map 0x0-0x1fffff to BAR 4 */
>>   					ranges = <0x0  0x4 0x0 0x0  0x200000>;
>> +
>> +					clock-controller@1004 {
>> +						compatible = "toshiba,tc9564-clock";
>> +						reg = <0x1004 0x10>;
>> +						clocks = <&tc9564_xo_board>;
>> +						#clock-cells = <1>;
>> +						#reset-cells = <1>;
>> +					};
> 
> [Severity: High]
> Can address translation for clock-controller@1004 succeed with dev@0,0's
> static placeholder ranges?
> 
> During PCI enumeration, pci_setup_device() -> pci_set_of_node() binds the
> static dev@0,0 node to the PCI device.  Because pci_device_to_OF_node() is
> then already non-NULL, the final fixup of_pci_make_dev_node() returns early
> without updating dev@0,0's ranges property.

This is correct.  This is a problem that must be solved
by another series I have had out for review for several
months.

   https://lore.kernel.org/lkml/20261105212412.591931-3-elder@riscstar.com/

The series causes a PCI function's ranges property to be
updated dynamically, even if the devicetree node for the
PCI device is non-null at the start of of_pci_make_dev_node().

> When tc9564_function_probe() populates the bus, of_address_to_resource()
> translates reg = <0x1004 0x10> via the stale BAR 4 range to 0x85004, outside
> pcie1's 0x40300000 MEM window in kodiak.dtsi.  of_device_alloc() then hits
> WARN_ON(rc) and tc9564_clk_probe() fails with -EINVAL.

I no longer recall precisely what happens but this sounds
about right.  Without the series mentioned above, address
mapping done by of_address_to_resource() fails.

I think this report from Sashiko is correct (and fairly
involved), but there is a proposed fix.

> [Severity: Medium]
> In the bound clock driver from commit "clk: toshiba: introduce a TC9564
> clock driver", does devm_reset_register() in drivers/clk/clk-tc9564.c free
> aux_data and the IDA ID while the auxiliary device is still registered?

What follows are repeated reports that were already mentioned
for patch 3 in this series.

					-Alex

> 
> __devm_auxiliary_device_create() registers auxiliary_device_destroy() as a
> devres action before returning.  Registering reset_adev_free() afterwards
> means LIFO teardown frees aux_data and calls ida_free() before
> auxiliary_device_destroy() removes the device:
> 
> CPU0                                CPU1
> devres_release_all()
>    reset_adev_free()
>      ida_free(&reset_ids, adev->id)
>      kfree(aux_data)
>                                      tc9564_reset_probe()
>                                        aux_data = dev_get_platdata(dev)
>                                        aux_data->regs  <-- use-after-free
>    auxiliary_device_destroy()
> 
> Registering cleanup for aux_data and the IDA ID before creating the
> auxiliary device avoids both the use-after-free and early ID reuse.
> 
> [Severity: Medium]
> Also in drivers/clk/clk-tc9564.c:devm_reset_register(), does the ida_alloc()
> error path leak aux_data?  aux_data is allocated with kzalloc_obj() right
> before ida_alloc(), but an allocation failure returns dev_err_probe()
> without calling kfree(aux_data).
> 


      reply	other threads:[~2026-12-04  2:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 20:09 [PATCH v5 0/4] clk: tc9564: introduce clock and reset drivers Alex Elder
2026-12-03 20:09 ` [PATCH v5 1/4] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml Alex Elder
2026-12-03 20:18   ` sashiko-bot
2026-12-04  2:42     ` Alex Elder
2026-12-03 20:09 ` [PATCH v5 2/4] reset: toshiba: introduce a TC9564 reset driver Alex Elder
2026-12-03 20:24   ` sashiko-bot
2026-12-04  2:42     ` Alex Elder
2026-12-04  9:42   ` Lorenzo Bianconi
2026-12-03 20:09 ` [PATCH v5 3/4] clk: toshiba: introduce a TC9564 clock driver Alex Elder
2026-12-03 20:22   ` sashiko-bot
2026-12-04  2:42     ` Alex Elder
2026-12-04  9:40   ` Lorenzo Bianconi
2026-12-03 20:09 ` [PATCH v5 4/4] arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node Alex Elder
2026-12-03 20:28   ` sashiko-bot
2026-12-04  2:43     ` Alex Elder [this message]

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=94d0865f-df47-463a-9f41-9acc07d4e9a6@riscstar.com \
    --to=elder@riscstar.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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