[PATCH] pmdomain: rockchip: fix domain check in rockchip_pm_add_one_domain()
Shawn Lin
shawn.lin at rock-chips.com
Sun Sep 20 23:36:25 PDT 2026
Hi Sergey,
在 2026/09/21 星期一 1:59, Sergey Shtylyov 写道:
> In rockchip_pm_add_one_domain(), there's the check (most probably for
> the case where the "reg" prop has an unexpected value?) which doesn't
Agreed that check indeed makes little sense. But "most probably for the
case where the reg prop has an unexpected value" does not hold: an
out-of-range reg value is already rejected by the "id >= pmu->info-
>num_domains" check above, and num_domains equals
ARRAY_SIZE(domain_info) for every SoC, so there are no holes in the
table that the new check could catch with the current data. AFAICT, this
patch does not change any runtime behaviour; it only turns dead code
into a defensive check on the match-data tables.
> make much sense as the variable pd_info will be NULL iff pmu->info->
> domain_info is NULL and the variable id is 0. What does make sense
> there is checking pd_info->pwr_mask and pd_info->req_mask which (as
> seems to follow from the code) can't both be 0 for a valid domain...
>
That means there is no bug being fixed here, should we drop the fixes tag?
> Found by Linux Verification Center (linuxtesting.org) with the Svace
> static analysis tool.
>
> Fixes: 7c696693a4f5 ("soc: rockchip: power-domain: Add power domain driver")
> Signed-off-by: Sergey Shtylyov <s.shtylyov at auroraos.dev>
>
> ---
> This patch is against the fixes branch of Ulf Hansson's linux-pm.git repo.
>
> drivers/pmdomain/rockchip/pm-domains.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pmdomain/rockchip/pm-domains.c b/drivers/pmdomain/rockchip/pm-domains.c
> index ba66ae719428..69792e2b215b 100644
> --- a/drivers/pmdomain/rockchip/pm-domains.c
> +++ b/drivers/pmdomain/rockchip/pm-domains.c
> @@ -809,7 +809,7 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu *pmu,
> return 0;
>
> pd_info = &pmu->info->domain_info[id];
> - if (!pd_info) {
> + if (!pd_info->pwr_mask && !pd_info->req_mask) {
> dev_err(pmu->dev, "%pOFn: undefined domain id %d\n",
> node, id);
> return -EINVAL;
More information about the linux-arm-kernel
mailing list