From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBE24394EA6 for ; Sat, 12 Sep 2026 07:04:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789196675; cv=none; b=c1Jggp235MidtkLJno+yCRhErKibA3zZuoEWG/oJbxp2N9+l1YE3Grd4dbrbpSXKdsmLz6Pz301JDDQAtG8YpvnqSk1aguOR+8eo0MzzWFBfa8iDthPCFY2ZGNkn+UQDEI1aCAEils6lpYP59jlJoBqg1MtlXoOvCkqOnHQroEA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789196675; c=relaxed/simple; bh=7PmjztBS6def2/u43VVM6riSESEGADER+ysNEo1Eido=; h=From:Subject:To:Cc:In-Reply-To:References:Content-Type:Date: Message-Id; b=FzeHCcftWrob+4mTgBEtozLEKKQLjd+FJKTSoE/WZX8dfnoXSl5iBUeQtUh1tsi2oHp2DajnWiUrSp/7hhpMPRAfIhnH9QSlqJ4XKvpt/+qfRgrhK6iEgmG+x/iDkbZvEWfAR9hFcAqclg6lNIQSf1CwUX0zMAf0tf+DsvgyJs0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NSvOkcrB; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NSvOkcrB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FC671F00898; Sat, 12 Sep 2026 07:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1789196668; bh=4dv41HOpv0fan4sCVCNO2u51UEEvzvPSNfZ78nUngdo=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=NSvOkcrBAAG5P015+DoiE9fkNOydNAoArz6dW2CC4D4GTj0W3CsP5wPPHgm4Ax5j7 tB+8zb2fnsQ4xXqZP3S3lTPrNGPxm4W+KbVWC2MQYUMA3BGTsct4jI1b6INPpQR1px sumiQGyNV81wvGj7PptzsVULCFh09pA8uMikZFy3S4jnDVGB6gD1sC73/WoF2ZJKFp /4VXpVChwGIBpU3ZM6X5HO8DKvRr8sJ7lVMax3iV3YIV5AFUZ5+SSQCPebGu4kFV5q LHTYnNZ1hOVf7QRLG+BuUTHNdF+R1DqIRCI3ifUSQFTXsw6RkOjt5rXU8oxrAs7gJP HhR9h6PFG2mhw== From: sashiko-bot@kernel.org Subject: Re: [PATCH v12 10/14] pmdomain: rockchip: cycle optional power-domain resets on power-on Reply-To: sashiko-reviews@lists.linux.dev To: "Jiaxing Hu" Cc: conor+dt@kernel.org, robh@kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org In-Reply-To: <20260912065053.1519165-11-gahing@gahingwoo.com> References: <20260912065053.1519165-1-gahing@gahingwoo.com> <20260912065053.1519165-11-gahing@gahingwoo.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 12 Sep 2026 07:04:27 +0000 Message-Id: <20260912070428.1FC671F00898@smtp.kernel.org> Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Thank you for your contribution! Sashiko AI review found 1 potential issue(= s) to consider: Pre-existing issues: - [High] Massive Use-After-Free of genpd structures if probe fails and pm_g= enpd_remove() fails during error cleanup. -- commit 82ba89727b40b24aa0ac406b6e9c71489c988d78 Author: Jiaxing Hu pmdomain: rockchip: cycle optional power-domain resets on power-on =20 Some Rockchip domains come out of power-on with their bus interface in = an undefined state. On the RK3576 NPU this shows up as a hang on the first register access after the domain is switched on, and pulsing the domain= 's resets at this point clears it. > diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/ro= ckchip/pm-domains.c > --- a/drivers/pmdomain/rockchip/pm-domains.c > +++ b/drivers/pmdomain/rockchip/pm-domains.c [ ... ] > @@ -949,6 +975,7 @@ static void rockchip_pm_remove_one_domain(struct rock= chip_pm_domain *pd) > =20 > clk_bulk_unprepare(pd->num_clks, pd->clks); > clk_bulk_put(pd->num_clks, pd->clks); > + reset_control_put(pd->resets); > =20 > /* protect the zeroing of pm->num_clks */ > mutex_lock(&pd->pmu->mutex); [Severity: High] This is a pre-existing issue, but does this error cleanup path leave a freed structure in the global gpd_list if probe fails? During error cleanup, rockchip_pm_domain_cleanup() iterates forward through the domains array: for (i =3D 0; i < pmu->genpd_data.num_domains; i++) { genpd =3D pmu->genpd_data.domains[i]; if (genpd) { pd =3D to_rockchip_pd(genpd); rockchip_pm_remove_one_domain(pd); } } Since parent domains typically appear before their children in the array, t= he parent is visited first.=20 When rockchip_pm_remove_one_domain() attempts to remove the parent domain, pm_genpd_remove() fails with -EBUSY because the child is still attached: ret =3D pm_genpd_remove(&pd->genpd); if (ret < 0) dev_err(pd->pmu->dev, "failed to remove domain '%s' : %d...", The domain is left in the global gpd_list and the function continues without retrying. Because rockchip_pm_add_one_domain() allocates the domain structure with devm_kzalloc(): pd =3D devm_kzalloc(pmu->dev, sizeof(*pd), GFP_KERNEL); When probe returns an error, such as -EPROBE_DEFER, devres automatically fr= ees the memory backing the parent domain.=20 Can this leave a dangling pointer in the global gpd_list that could trigger= a use-after-free or kernel panic when the list is next traversed, such as during pm_genpd_poweroff_unused()? Should rockchip_pm_domain_cleanup() be updated to iterate backwards to ensure children are removed before their parents? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260912065053.1519= 165-1-gahing@gahingwoo.com?part=3D10