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=1796050304; b=Iw/ZdGHR6Q7Tqmqtfp+CAIwiw+92LKF2w/czuv1bJXbHKpE2tZ8Wwzz6A9GN7sMQq+9G xBmqnv4lVIuZGoK/kEgzqk25zfg3HMAsIEHFppuUDo48oMe1zGa3RrFcfMCEvmHWVojPR wkMbKav+Xj2xd7UGgeV/OiqQ8hAWz9Or89X+qkjOntk5ujX7sTj5uODM3p+CnVY4269c4 RY9zC4o1tQeMMGI3RaNArfA1ViO/PUNZrQvgN11M5lJFrY2ESn+juP790lKTtdwieZ29O oyaTDi2bBmPLVr0dijwkj1jSXmgeZKUu3DhnE74pTVz0zcUNWTc1KNaryShVDw7BQhw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796050304; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition: Content-Transfer-Encoding:In-Reply-To; bh=F/lVVLrHq3a6APRKGLIj3oq5cHKCdB9c++rVnl7Cp9s=; b=O6DGfzTPH65VH088ZJAAaOlwM5rBN1zJdTwAhgfKA19U9WeuYMoWNsewxPiRCalo+jp4 xBzt3Wckud1C9oPlQYS2RQGvzeo0YqJVP3mZ4jl1GKJ9IP3KTBUlDCJx3ZBb6ZhG55Nez O3EegATD+9EmpBy9nzO6Qrb3jbeDFh7kXOt1BCAVsTKiArlFyKlC4/5FnBpJHOTpPgIZG 9rJFOBtFegEM3FVbgqCJOp9kd+Leps4jA7lN5k9Jj4mQxKIPrU50ELJUMzaXUZX9vJKn+ ggFmg1mdkGG0LVi9HmpC+rFaCG/yBLGPTa07E5Bf8cgN6W6okuCVXVMvpmZCUX3Lw/Q== 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=RFK+z7hZ; 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 30B22606A31C; Mon, 30 Nov 2026 14:51:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=RFK+z7hZ 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-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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