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 01750606A31C for ; Mon, 30 Nov 2026 14:52:01 +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=Fj1z3qsr; dkim=pass (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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type: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=F/lVVLrHq3a6APRKGLIj3oq5cHKCdB9c++rVnl7Cp9s=; b=Fj1z3qsryA+83tLVHvpPzjNywQ GygJeDpdpo7jvfLnzZxDNPHm2XkFOPuJecXxMTy23FYiqWCA9t4aXIWmMrrFPiqG3sSONak/M5Ffr r5nyMdlkuHam/9g3UJASo0635txhLa3Siii6BcPkWaC9cSeBIVBMKv2/OT37bVeZHtGE8y5dHAtdP qiJXxCayuWuvyEvAKr1i6pCwU77QveQ4WH3UDa1BCG8wqFV3LIGhBAtGFZqlCj6CMBDgKGq1Ge5j4 VYa8fW0Ve1XLoW/06IEKg78IA5caER3jJl7iy28zq3iLrdfUSZvL0bW33zMEZtp6y+BspPG75HEQI PNM0T2bQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xY2jK-00000004xeZ-1S9w; 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-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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äische Normalzeit schrieb 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-7b25245ccd06 > > 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 char *name, > > goto free_alt_parent; > > } > > > > - ret = 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 = nrates; > > cpuclk->rate_table = kmemdup_array(rates, nrates, sizeof(*rates), > > GFP_KERNEL); > > if (!cpuclk->rate_table) { > > ret = -ENOMEM; > > - goto unregister_notifier; > > + goto free_alt_parent; > > } > > + cpuclk->rate_count = nrates; > > + } > > + > > + ret = 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 = 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 = 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