From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAB4E606A31C for ; Mon, 30 Nov 2026 14:51:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=nFp7Sxuq; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RFK+z7hZ DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=fuz7hju/pFPlmx9keGI/LJVz1vBNPZVrjgaWdeA+DHo=; b=nFp7Sxuqp1g2k71s9tndvXAQ16 Ln31N8cWunxE/DPcpap4dP2NMFqCKifyyID7x5K8WXdIpZK7acZlb5WuNKSm9AdYCpzokV/orJ7G8 fiqLXbiToHSIUSJd+CfxdY69icwTrVM4bWa+hDDNiyU+GAxQ6HnyZOYJKHqF6WzcnYmKWEon1l0ik cHvBNacxKBcG5WD61XL+Hs2BqCg3sZoqNlx68NLnnUoE23sGIVEp6RLmz4RitC55/XUs+aum8XlBE w0UMtm87jv0nMLildcf/kINfxEuXq+He3ghFwMtWlcDcsOLWkQM0GVSuS9rw66EzaNUkr03haTvBV IfzkLJrA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY2jK-00000004xek-20av; Mon, 30 Nov 2026 14:51:46 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY2jI-00000004xdp-46Ox; Mon, 30 Nov 2026 14:51:45 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 147826217E; Mon, 30 Nov 2026 14:51:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7455B1F00897; Mon, 30 Nov 2026 14:51:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796050303; bh=F/lVVLrHq3a6APRKGLIj3oq5cHKCdB9c++rVnl7Cp9s=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=RFK+z7hZuMt0nxMTWMaqWfpSz7oazcA6ScUWrpF75PmZwslpoYQ3CPYLPaU2VsfKH Hxv1P/ljSw7N/btsW++TKQ34+hralfh9kq7k2a3eIZwkY4F+uoqXRgMGq49e4hkocs IOQbYebgPY8keMyaMJo6R3+5PaAc3HGYqJTpZUF+9sAIe8fq8YG+M4C+e4TwOuzEYm OYgvWqaC67IffIeDmm8UPLVFW1elqCcM3xo/Nf42h7Fo/MEsNvwQSbjL9QxA7CwQ/N WmxLdcQ3nchBxGOCE86/G+8NgZPECYswjdXGCyObrMJTf54NtmMirjbtSkDq2W8Adm uiZxBAQ33q7vg== Date: Mon, 30 Nov 2026 14:51:38 +0000 From: Lee Jones To: Heiko Stuebner Cc: Stephen Boyd , Brian Masney , Jerome Brunet , Thomas Abraham , Doug Anderson , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 05/10] clk: rockchip: cpu: Allocate rate_table before registering notifier Message-ID: <20261130145138.GB90630@joneslee-mac.roam.internal> References: <20261127192620.3443537-1-lee@kernel.org> <20261127192620.3443537-6-lee@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "Linux-rockchip" X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Sun, 29 Nov 2026, Heiko Stuebner wrote: > Am Freitag, 27. November 2026, 20:25:29 Mitteleurop=E4ische Normalzeit sc= hrieb Lee Jones: > > rockchip_clk_register_cpuclk() registers cpuclk->clk_nb before > > allocating cpuclk->rate_table, and on clk_register() failure frees > > cpuclk->rate_table before unregistering the notifier. A concurrent > > parent rate change can therefore observe a NULL rate_table while > > rate_count is already non-zero, or dereference the freed rate_table > > before clk_notifier_unregister() completes. > > = > > Allocate and populate cpuclk->rate_table before calling > > clk_notifier_register(), and reverse the error-path teardown so the > > notifier is unregistered before cpuclk->rate_table is freed. > > = > > Fixes: f6fba5f6967d ("clk: rockchip: add new clock-type for the cpuclk") > > Closes: https://sashiko.dev/#/bug/linux-c0f18cf6-69e2-4cc3-8b2b-7b25245= ccd06 > > Cc: stable@vger.kernel.org > > Signed-off-by: Lee Jones > > --- > > drivers/clk/rockchip/clk-cpu.c | 26 +++++++++++++------------- > > 1 file changed, 13 insertions(+), 13 deletions(-) > > = > > diff --git a/drivers/clk/rockchip/clk-cpu.c b/drivers/clk/rockchip/clk-= cpu.c > > index eb6b8b878e4d..27d5b6f6987d 100644 > > --- a/drivers/clk/rockchip/clk-cpu.c > > +++ b/drivers/clk/rockchip/clk-cpu.c > > @@ -360,36 +360,36 @@ struct clk *rockchip_clk_register_cpuclk(const ch= ar *name, > > goto free_alt_parent; > > } > > = > > - ret =3D clk_notifier_register(clk, &cpuclk->clk_nb); > > - if (ret) { > > - pr_err("%s: failed to register clock notifier for %s\n", > > - __func__, name); > > - goto free_alt_parent; > > - } > > - > > if (nrates > 0) { > > - cpuclk->rate_count =3D nrates; > > cpuclk->rate_table =3D kmemdup_array(rates, nrates, sizeof(*rates), > > GFP_KERNEL); > > if (!cpuclk->rate_table) { > > ret =3D -ENOMEM; > > - goto unregister_notifier; > > + goto free_alt_parent; > > } > > + cpuclk->rate_count =3D nrates; > > + } > > + > > + ret =3D clk_notifier_register(clk, &cpuclk->clk_nb); > > + if (ret) { > > + pr_err("%s: failed to register clock notifier for %s\n", > > + __func__, name); > > + goto free_rate_table; > > } > > = > > cclk =3D clk_register(NULL, &cpuclk->hw); > > if (IS_ERR(cclk)) { > > - pr_err("%s: could not register cpuclk %s\n", __func__, name); > > + pr_err("%s: could not register cpuclk %s\n", __func__, name); > > ret =3D PTR_ERR(cclk); > > - goto free_rate_table; > > + goto unregister_notifier; > > } > > = > > return cclk; > = > nothing against this patch, but it's interesting that sashiko did not > notice that rockchip_clk_register_cpuclk_multi_pll() has a similar > pattern? I have 59 clk fixes to work my way through. Perhaps it's one of those? -- = Lee Jones _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip