From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796142077; b=TXhJ4O6X0ijuHI6SefpQkUKP8TFCk+e8i4oorjjhIeeseBck+MnF4c76N9+somFG4AkR 7D3SkV5PuprFZWNM+/irf5evHZ4ZLtgFiJ4ky65cLzyALSwEfonnN2D70GV9QKIi83/9w Jeh4qn7MhC+ddXJLn6UhsbCTLzRTx7maBsdYKMXreLNzIbHXSOvec8Zj3F1MV9/sKEI89 xIWmBR0A5XQ2pBPkcDZN2afuNF1K+6ssvutg+e2DCNee7SV83WN/QNYUB2f6zyPSSaM8N KD//2CmM7AdsXX2xYMV9qhBA9e/rA2ChFgWEL4vMe0P/wsIApZLUzrHodLml+BjX8Ew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796142077; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=VDNlJN7HEuV69DxKE/eU1K2U0YEZOStp7LA6PwdLpyY=; b=XU9lgUjz9Y7FELLVri5wsH78rQkL+Uo4kLPZXB3A3u42eeQow4nrOALt0P0it6owBZXd mGZzd1Vr4ijtyiUUaj5ULW9qEXt3yao8R2FRLUoiihHwKNRIfCLfFqrQnt32T86SdXpdD HUTYgk5KuBI5ciRB9kib46A0y0IfkB1qZOCdHYU4lCE1+/KC+KS4uzVrAZ+Bj+0D3aA7n wtq+drPJsfE8bx0x86SGSI0/02JUvWYVJRIf4crFmhn6VQgcgY/1Bbm+bmQYOGbv2cfhx Xx/w4vv72xTVBmZ6QDe3Zq2yGB9qYEHUfs+d38o1mAgsFyk3Bik1Efpo8ZaFw74waxQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Kd8caqj3; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB1FC606E619; Tue, 1 Dec 2026 16:21:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Kd8caqj3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21E3A1F00931; Tue, 1 Dec 2026 16:21:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796142077; bh=VDNlJN7HEuV69DxKE/eU1K2U0YEZOStp7LA6PwdLpyY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Kd8caqj3u+i1s6ogeq3b6LTDg4AvCHW4X068uBRXjdXymQVsZkm6YhuRh4zLSvzRt 9ZPzIZvMNAAakEQum98VMRDzyXmNRZEhdyQO+vWiSnSi6D+DIO0/s4yK4ti/tRwTUk +ZnFyPb9f/zYdjbIGc1qwnGGsfjnIBy4h5jbYaz6BumAmOq/XNo6MUlGl73NTqGsdk qMMQOlcve+AIqpoMxCtWNmngQHjRVecCFYBbNwc/OAPEHeozYyGBL9VQiu7rok1zCQ 24tOfNeUWRznjglDwoNYGeeuGwvx+zoVRJ7U1eTHzDktc36XTYfA0cMOpSw4RQ9VSn H6L4LWCMHwYuA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v4 2/4] clk: toshiba: introduce a TC9564 clock driver Reply-To: sashiko-reviews@lists.linux.dev To: "Alex Elder" Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org In-Reply-To: <20261201160810.2422466-3-elder@riscstar.com> References: <20261201160810.2422466-1-elder@riscstar.com> <20261201160810.2422466-3-elder@riscstar.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 16:21:15 +0000 X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [Medium] clk: tc9564: conflicting OF clock providers registered on same DT node - [Medium] clk: tc9564: premature kfree() of reset_aux outside reset_dev_release() - [Medium] clk: tc9564: missing select AUXILIARY_BUS in Kconfig for COMMON_CLK_TC9564 - [Low] clk: tc9564: hardcoded adev->id in devm_reset_setup() breaks multi-instance - [Low] clk: tc9564: unused lock field, write-only gate_data, and reset header -- commit 36b5909afe8d085c12caff8d18e2b1828c4c5a70 Author: Alex Elder clk: toshiba: introduce a TC9564 clock driver This commit adds a platform driver for the Toshiba TC9564 SoC clock controller and registers an auxiliary device for the SoC reset controller. > diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig > index 6bfa2c8fffe1b..a3d89c55f17a5 100644 > --- a/drivers/clk/Kconfig > +++ b/drivers/clk/Kconfig > @@ -185,6 +185,14 @@ config COMMON_CLK_CDCE706 > help > This driver supports TI CDCE706 programmable 3-PLL clock synthesizer. > =20 > +config COMMON_CLK_TC9564 > + tristate "Toshiba TC9564 clock support" > + help > + This enables support for the clock controller embedded in the > + Toshiba TC9564 SoC. It is also required to support the embedded > + reset device, which is represented as an auxiliary device created > + by the clock controller driver. [Severity: Medium] Should COMMON_CLK_TC9564 select AUXILIARY_BUS? devm_reset_setup() calls auxiliary_device_init() and auxiliary_device_add(), which are only built when CONFIG_AUXILIARY_BUS is enabled, so linking fails with undefined references when no other enabled driver selects AUXILIARY_BUS. > diff --git a/drivers/clk/clk-tc9564.c b/drivers/clk/clk-tc9564.c > new file mode 100644 > index 0000000000000..ec72a0207fd87 > --- /dev/null > +++ b/drivers/clk/clk-tc9564.c > @@ -0,0 +1,401 @@ [ ... ] > +#include > +#include > +#include [ ... ] > +struct tc9564_clock { > + void __iomem *ioaddr; /* Mapped clock/reset registers */ > + spinlock_t lock; /* Protects reset register updates */ > + struct clk_hw *pll_hw; > + struct clk_hw_onecell_data *fixed_data; > + struct clk_hw_onecell_data *gate_data; > +}; [Severity: Low] This isn't a bug, but and clock->lock appear to be unused leftovers from splitting out the reset driver, and clock->gate_data is only written in gate_clock_setup() and never read. [ ... ] > +/* Initialize the PLL (parent is the input oscillator); called from prob= e */ > +static int pll_setup(struct device *dev) > +{ > + const char *name __free(kfree) =3D clock_name_alloc(dev, "pll"); > + struct tc9564_clock *clock =3D dev_get_drvdata(dev); > + struct clk_hw *hw; > + int ret; > + > + if (!name) > + return -ENOMEM; > + > + hw =3D devm_clk_hw_register_fixed_factor_index(dev, name, 0, 0, 50, 1); > + if (IS_ERR(hw)) > + return dev_err_probe(dev, PTR_ERR(hw), > + "failed to register pll\n"); > + > + ret =3D devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, hw); > + if (ret) > + return dev_err_probe(dev, ret, "failed to add pll provider\n"); > + > + clock->pll_hw =3D hw; > + > + return 0; > +} > + > +/* Initialize the fixed rate clocks (PLL is parent); called from probe */ > +static int fixed_clock_setup(struct device *dev) > +{ [ ... ] > + ret =3D devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, > + fixed_data); > + if (ret) > + return dev_err_probe(dev, ret, > + "failed to add fixed clock provider\n"); > + > + clock->fixed_data =3D fixed_data; > + > + return 0; > +} > + > +/* Initialize the gate clocks; called from probe */ > +static int gate_clock_setup(struct device *dev) > +{ [ ... ] > + ret =3D devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get, > + gate_data); > + if (ret) > + return dev_err_probe(dev, ret, > + "failed to add gate clock provider\n"); > + > + clock->gate_data =3D gate_data; > + > + return 0; > +} [Severity: Medium] Should only gate_clock_setup() call devm_of_clk_add_hw_provider()? Calling devm_of_clk_add_hw_provider() in pll_setup(), fixed_clock_setup(), and gate_clock_setup() registers three OF clock providers on the same dev->of_node. Because the PLL and fixed-factor clocks are wired as internal parents via clk_hw pointers and the DT binding only exports the gate clocks, the extra providers mark the DT node initialized and run of_clk_set_defaults() before the gate clocks exist. Also, in of_clk_get_hw_from_clkspec(), any out-of-range clock index falls through gate_data and fixed_data to of_clk_hw_simple_get(), returning pll_hw instead of -EINVAL. > + > + > +static void reset_dev_release(struct device *dev) > +{ > + of_node_put(dev->of_node); > +} > + > +static struct reset_aux *adev_to_reset_aux(struct auxiliary_device *adev) > +{ > + return container_of(adev, struct reset_aux, adev); > +} > + > +static void reset_adev_remove(void *data) > +{ > + struct auxiliary_device *adev =3D data; > + > + auxiliary_device_delete(adev); > + auxiliary_device_uninit(adev); > + kfree(adev_to_reset_aux(adev)); > +} > + > +/* Create the TC9564 reset auxiliary device */ > +static int devm_reset_setup(struct device *dev) > +{ > + struct tc9564_clock *clock =3D dev_get_drvdata(dev); > + struct tc9564_aux_data *aux_data; > + struct auxiliary_device *adev; > + struct reset_aux *reset_aux; > + int ret; > + > + reset_aux =3D kzalloc_obj(*reset_aux); > + if (!reset_aux) > + return -ENOMEM; > + adev =3D &reset_aux->adev; > + > + aux_data =3D &reset_aux->aux_data; > + aux_data->reg =3D clock->ioaddr; > + > + adev->id =3D 0; > + adev->name =3D TC9564_RESET_DEV_NAME; [Severity: Low] Will hardcoding adev->id =3D 0 fail when a system has more than one TC9564 instance? A second instance registers the same "clk_tc9564.tc9564-reset.0" name on the auxiliary bus and fails in auxiliary_device_add() with -EEXIST. > + adev->dev.parent =3D dev; > + adev->dev.platform_data =3D aux_data; > + adev->dev.release =3D reset_dev_release; > + device_set_of_node_from_dev(&adev->dev, dev); > + > + ret =3D auxiliary_device_init(adev); > + if (ret) { > + of_node_put(adev->dev.of_node); > + kfree(reset_aux); > + return ret; > + } > + > + ret =3D auxiliary_device_add(adev); > + if (ret) { > + auxiliary_device_uninit(adev); > + kfree(reset_aux); > + > + return ret; > + } [Severity: Medium] Can freeing reset_aux right after auxiliary_device_uninit(adev) in devm_reset_setup() and reset_adev_remove() cause a use-after-free on adev->dev? Once auxiliary_device_init() succeeds, adev->dev is a reference-counted device whose memory must be freed in its release callback. If another reference to adev->dev is still held when auxiliary_device_uninit() calls put_device() (or when CONFIG_DEBUG_KOBJECT_RELEASE delays release), kfree() frees reset_aux before reset_dev_release() runs. Moving kfree(adev_to_reset_aux(to_auxiliary_dev(dev))) into reset_dev_release() and dropping the kfree() calls after auxiliary_device_uninit() avoids this. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201160810.2422= 466-1-elder@riscstar.com?part=3D2