]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PM / devfreq: hisi: Fix potential UAF in OPP handling
authorPengjie Zhang <zhangpengjie2@huawei.com>
Mon, 15 Sep 2025 06:21:35 +0000 (14:21 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:03:11 +0000 (14:03 +0100)
[ Upstream commit 26dd44a40096468396b6438985d8e44e0743f64c ]

Ensure all required data is acquired before calling dev_pm_opp_put(opp)
to maintain correct resource acquisition and release order.

Fixes: 7da2fdaaa1e6 ("PM / devfreq: Add HiSilicon uncore frequency scaling driver")
Signed-off-by: Pengjie Zhang <zhangpengjie2@huawei.com>
Reviewed-by: Jie Zhan <zhanjie9@hisilicon.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Link: https://patchwork.kernel.org/project/linux-pm/patch/20250915062135.748653-1-zhangpengjie2@huawei.com/
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/devfreq/hisi_uncore_freq.c

index 96d1815059e32c4e70a1d3c257655cc6b162f745..c1ed70fa0a4004e29ecc3fcd4c6b6375287a8143 100644 (file)
@@ -265,10 +265,11 @@ static int hisi_uncore_target(struct device *dev, unsigned long *freq,
                dev_err(dev, "Failed to get opp for freq %lu hz\n", *freq);
                return PTR_ERR(opp);
        }
-       dev_pm_opp_put(opp);
 
        data = (u32)(dev_pm_opp_get_freq(opp) / HZ_PER_MHZ);
 
+       dev_pm_opp_put(opp);
+
        return hisi_uncore_cmd_send(uncore, HUCF_PCC_CMD_SET_FREQ, &data);
 }