]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
pmdomain: mediatek: mfg: initialize prev_o in mtk_mfg_attach_dev()
authorKarl Mehltretter <kmehltretter@gmail.com>
Sat, 8 Aug 2026 15:05:06 +0000 (17:05 +0200)
committerUlf Hansson <ulfh@kernel.org>
Wed, 12 Aug 2026 09:09:12 +0000 (11:09 +0200)
mtk_mfg_attach_dev() reads prev_o on the first iteration of its loop,
in "if (prev_o && prev_o->freq == o->freq)", before prev_o is assigned
at the end of the loop body. On that first iteration, evaluating prev_o
reads an indeterminate value. If it is non-NULL, the condition
dereferences a stale or invalid pointer, potentially faulting or
incorrectly skipping the first OPP.

Initialize prev_o to NULL. This matches the intent as well: there is no
previous OPP to compare against on the first iteration.

Found with Clang's -Wconditional-uninitialized.

Fixes: f08e7a4e8d6ac ("pmdomain: mediatek: Add support for MFlexGraphics")
Assisted-by: Claude:claude-fable-5
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
Reviewed-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Cc: stable@vger.kernel.org
Signed-off-by: Ulf Hansson <ulfh@kernel.org>
drivers/pmdomain/mediatek/mtk-mfg-pmdomain.c

index 53bdab66cf1578dbde2d7f27fba5c83733de10e6..9a8a38d98cce77408eba5da446a8556c865506f4 100644 (file)
@@ -657,7 +657,7 @@ static int mtk_mfg_attach_dev(struct generic_pm_domain *pd, struct device *dev)
        struct mtk_mfg *mfg = mtk_mfg_from_genpd(pd);
        struct dev_pm_opp_data *so = mfg->stack_opps;
        struct dev_pm_opp_data *go = mfg->gpu_opps;
-       struct dev_pm_opp_data *prev_o;
+       struct dev_pm_opp_data *prev_o = NULL;
        struct dev_pm_opp_data *o;
        int i, ret;