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=1796108085; b=dxmW9NVbvbmcLpA6F5c6a9N8tu5FN8Aay41QHBrbA4rRMO0I+w/uW98ic4uDa2rmpYHF 7iCkYPPNmHECJ46sNruvtWL61q6hU/1wmQisITOmdCMt9ziMiO1BI5p3RESnwvk0/J3/l xYHp5rTLv31jXaGGqfGmgdtBWvjg7MKnrtjha34graD2KXOxmRauUuuEKpQm1biD5Zp1H ftFOKvjiN3sJ87qde+y/0HM9qsso862dTv6otgZxIj97w7hpHdwPta/KwbnME2SOeS57R 7Q209bKZS6/ukaor7PPTt6cBzh7EYVsaJM74vtaUNxtw3EQXff12XVIpV2JOWrZbV7w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796108085; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=kGnHcpqmsL+3eDgif5qb5vDitPRA2OioB9trnRRwYIY=; b=PN5G9bs5HAKyfckflRi8uIwOl9ykVOQgB1t8Rvsqjq8wQbLJuoh+d9/SyFC0FUQ+xitm MvNuOp/kND3q3A2hEQLtKYwMxgkicQ6QTt3+8sUjHwocLP4jdqC0IDlMAm+ljhzhqdLBX Hrljqe2s+Iu7ERAAMaUedjtH+3x8dlyRYEJoapRLlA1wAVD2B3XtMgtUaXYIRbu1tBkDM ZLzDfijoAFfuplaPiJRg88bUx+TfhOCTcG2H4fMPuM38V5wh0z7+50rpFPhLajDjkzvhq KwvC5N07YG08cE/ZQhEOprc4GvZ4M6odbueRtGzyoHWPAxBbYlWfnRp2ZUZ9hJ0W0Hw== 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=OW75UIhS; 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 E5295606A338 for ; Tue, 1 Dec 2026 06:54:44 +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=OW75UIhS Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5753C1F000C1; Tue, 1 Dec 2026 06:54:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796108084; bh=kGnHcpqmsL+3eDgif5qb5vDitPRA2OioB9trnRRwYIY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=OW75UIhSh+hp+70Hw3hwrm+o2wlw4eAzyuK31MsHP2bcDYBU+tddQClD3kalQPycN aacTtuASJCHwfm1S8zw0meotPlBe0Av2ANPOnTTw+FvgR14wWxlUndr4u3B/sJIElF KHgwy24/CfzVZT9Ru4zfiBhFG5O8cQ+o6bVZUm+g0pONmahKVol85cceZE7BwbIj12 KPE80w+Qmw2BOw0fRqrCNRpk1oROYG+/U5qJsjYIEuwtY8k0XeKU5u7rPO7RH4tSZz 4rASwpeTeWpxlkeMiPJeaux9tEQG+BTMzyTinDHc4SvabRk2MJCnM5uZTx1VqmRo3H FqU1mvvPYN14w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 3/3] clk: zynqmp: Fix unchecked type index into clock topology tables Reply-To: sashiko-reviews@lists.linux.dev To: "Radhey Shyam Pandey" Cc: linux-clk@vger.kernel.org In-Reply-To: <20261201064353.238312-4-radhey.shyam.pandey@amd.com> References: <20261201064353.238312-1-radhey.shyam.pandey@amd.com> <20261201064353.238312-4-radhey.shyam.pandey@amd.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 06:54:43 +0000 X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] clk: zynqmp: stale num_nodes on error in zynqmp_clock_get_topology() -- commit 77850bd46c12a2a7c44b3c382e25533305881a70 Author: Beesam Sridhar Sagar clk: zynqmp: Fix unchecked type index into clock topology tables This commit validates the clock topology type returned by firmware against the size of clk_topology[] and propagates the error from __zynqmp_clock_get_topology(). > diff --git a/drivers/clk/zynqmp/clkc.c b/drivers/clk/zynqmp/clkc.c > index 5d827b2bb0ad3..4ce376023d7fd 100644 > --- a/drivers/clk/zynqmp/clkc.c > +++ b/drivers/clk/zynqmp/clkc.c > @@ -418,6 +418,8 @@ static int __zynqmp_clock_get_topology(struct clock_t= opology *topology, > type =3D FIELD_GET(CLK_TOPOLOGY_TYPE, response->topology[i]); > if (type =3D=3D TYPE_INVALID) > return END_OF_TOPOLOGY_NODE; > + if (type >=3D ARRAY_SIZE(clk_topology)) > + return -EINVAL; > topology[*nnodes].type =3D type; > topology[*nnodes].flag =3D FIELD_GET(CLK_TOPOLOGY_FLAGS, > response->topology[i]); > @@ -459,6 +461,8 @@ static int zynqmp_clock_get_topology(u32 clk_id, > num_nodes); > if (ret =3D=3D END_OF_TOPOLOGY_NODE) > return 0; > + if (ret < 0) > + return ret; > } > =20 > return 0; [Severity: Medium] Does returning an error here without resetting *num_nodes to 0 leave a partially populated topology when an invalid type appears after one or more valid nodes? In zynqmp_get_clock_info(), a failure from zynqmp_clock_get_topology() skips zynqmp_clock_get_parents(), leaving clock[i].num_nodes > 0 and clock[i].num_parents =3D=3D 0 while the clock remains valid: drivers/clk/zynqmp/clkc.c:zynqmp_get_clock_info() { ... ret =3D zynqmp_clock_get_topology(i, clock[i].node, &clock[i].num_nodes); if (ret) continue; ret =3D zynqmp_clock_get_parents(i, clock[i].parent, &clock[i].num_parents); ... } zynqmp_register_clocks() then calls zynqmp_register_clk_topology() on the partial nodes with total_parents =3D=3D 0 and an untouched parent_names[] array. Callbacks such as zynqmp_clk_register_fixed_factor() and zynqmp_clk_register_gate() unconditionally pass parent_names[0] to the clock framework, dereferencing either an uninitialized stack pointer or the clk_out[j] buffer freed at the end of the previous clock's zynqmp_register_clk_topology() call. Resetting *num_nodes =3D 0 before returning a negative error from zynqmp_clock_get_topology() would prevent registering the partial nodes. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201064353.2383= 12-1-radhey.shyam.pandey@amd.com?part=3D3