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 C9F90606A323 for ; Sun, 29 Nov 2026 16:42:39 +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=pjg0ed02; 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=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:Cc:To:From: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=8b6CeBG+LhAq9+RVoIYphAyGlJ8F9NUMWy4ZeOF5f9s=; b=pjg0ed029jg5UucGviB41fg/kQ wITQyIyqG8jzECFAYn/XQxjAfDEdnVb/MZm1G7ot9QUtD6WM3TdCiajbh8X7LgaTuVdWRWbvYqE6/ aw3Wm+AcBl6bm4SKNdF7Sbkqfd4K+GvK9tQjYj6GAVCLjpgUBPgaTUCHdPdk8h4Rt7NLThFz9AD0i ip0NOmEfhymz9O+umwDQKRLW4WmVKYJrPEJYhZ09FWJTq4mnGuxFf9+fMbtpNJinWLFnAI+gUg24l 71lFFy9zuAFFRE+7LBbkyvV5SpY43X/H97hsCAUSYhi2eair108pMbMNoSoU9g8i687IJvcn2Lrok keK0IhAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXhyt-00000002GOR-1xIz; Sun, 29 Nov 2026 16:42:27 +0000 Received: from gloria.sntech.de ([185.11.138.130]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xXhyq-00000002GNc-2YRj; Sun, 29 Nov 2026 16:42:25 +0000 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-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261129_084224_653488_8F8847F2 X-CRM114-Status: GOOD ( 18.55 ) X-Spam-Score: -2.1 (--) 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 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