From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.11.138.130 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795970548; b=rgZTjQz/aZhKi+9TV8KtJf9eHA2KAyMIvcg5yYwNZcUKhTS8l5j2OwHshu6w7WKshr7Y 8pJDAQD7Elg2iVobknLzR/U0lgtQ2fuNRmzDYsKpvBBzCwyKs/aFTOkO0n/fZPiCRxyVw jlkTOAyU29q6yq3rgaWUg62sIRDMzHTF9NvMYFAfD1RDP+/qhB7dyQtmD/ttibpKZCSrQ NiPHgoG8xyBtL9z/khetv6rjhrLANw8rwW++juq28CWrLnx1R76CCIAu+5t15GIESy+gz kv7zz0xnT3PU0u/DVAwxW1j6Zrpyz49nB3WQpqXl8ErFnjH5EQ6m/YjthRJAwwzVHOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795970548; h=DMARC-Filter:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding: Content-Type; bh=8b6CeBG+LhAq9+RVoIYphAyGlJ8F9NUMWy4ZeOF5f9s=; b=St7sXHHmbqdYrlgYnV3kCFuBjAaRcvP/DfRNJgD2OrpEfcdG4v0Fi8JYIgBgugFGxFc+ 3JV+dPH8CuLsIhbiz8HiurlHxtWUAhyXrKAdKFkKCwJDKlh8txNVDgEOTASYWqERfALx/ BS5DoIzap5wmtZnF0qZerGHkG8rrTCUrQAzZ8PUqPlhr6w8LOX8EK/YItrBnIPkGhZRq/ +gu2vofO4ky8WktqSQdQoJlh8lhS8CFqCsx+zdx6m0wTJATdA2B1oH3btG2ghIycRLOIY ARsmAac4fi014l3FLrQvyiBiODLC9NgEcFS45IupkcbQse/Ctl9Af9cLsCndWbTjG4g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=sntech.de; spf=pass smtp.mailfrom=sntech.de; dkim=pass header.d=sntech.de header.i=@sntech.de header.a=rsa-sha256 header.s=gloria202408 header.b=pxGAcs4Q; arc=none smtp.remote-ip=185.11.138.130 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBDD2606A31C; Sun, 29 Nov 2026 16:42:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DBDD2606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=sntech.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sntech.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sntech.de header.i=@sntech.de header.a=rsa-sha256 header.s=gloria202408 header.b=pxGAcs4Q DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sntech.de; s=gloria202408; h=Content-Type:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Reply-To; bh=8b6CeBG+LhAq9+RVoIYphAyGlJ8F9NUMWy4ZeOF5f9s=; b=pxGAcs4QromTjS9b4YT5Z6p1Z/ hnDITyf+7Ytx6Kk60/FQVIaY+3r7v/2Bt8zlUog/QAocqmd85JSxUFp3l7FUPmIPlWwCahqqxNMuB VJ+kLjr8x5AuJaI7XSyzyqVaUeeiKtr+1dVvW2th/hWRv+K3ASKqXVuSGKu3h5ASIg09t2wERWBe8 ikqDnGkyvveg8JFg7H2J58Kn81jSwwCTbObVnKl9epOFuSxbRMk7Shnd+0D2kCjndG8Cxl0XQpVZR HllGyu70piGaUI3dNiyIza/5u5WGToOIbG2zsF2POOAYae0AK72WVESHf1eUBnF6dQgnI87QypuCy s2GbE4IQ==; From: Heiko Stuebner To: lee@kernel.org, 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, Lee Jones Cc: stable@vger.kernel.org Subject: Re: [PATCH 05/10] clk: rockchip: cpu: Allocate rate_table before registering notifier Date: Sun, 29 Nov 2026 17:42:17 +0100 Message-ID: In-Reply-To: <20261127192620.3443537-6-lee@kernel.org> 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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Am Freitag, 27. November 2026, 20:25:29 Mitteleurop=C3=A4ische Normalzeit s= chrieb 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. >=20 > 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. >=20 > Fixes: f6fba5f6967d ("clk: rockchip: add new clock-type for the cpuclk") > Closes: https://sashiko.dev/#/bug/linux-c0f18cf6-69e2-4cc3-8b2b-7b25245cc= d06 > Cc: stable@vger.kernel.org > Signed-off-by: Lee Jones > --- > drivers/clk/rockchip/clk-cpu.c | 26 +++++++++++++------------- > 1 file changed, 13 insertions(+), 13 deletions(-) >=20 > diff --git a/drivers/clk/rockchip/clk-cpu.c b/drivers/clk/rockchip/clk-cp= u.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; > } > =20 > - 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; > } > =20 > 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; > } > =20 > 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? (notifier before ratet-table and rate-count before kmemdup) Heiko