diff options
author | Fei Shao <fshao@chromium.org> | 2021-10-14 20:03:51 +0800 |
---|---|---|
committer | Jassi Brar <jaswinder.singh@linaro.org> | 2021-10-19 12:28:09 -0500 |
commit | 5c154b6a51c2d2d7f266b3ef49b7dd1dc8cb5b65 (patch) | |
tree | eda1b2de30039a055c2e69f663d4a62fb865e5bb /drivers | |
parent | ce1537fe288469bf68ee0aabdb860a790b4755ef (diff) |
mailbox: mtk-cmdq: Validate alias_id on probe
of_alias_get_id() may return -ENODEV which leads to illegal access to
the cmdq->clocks array.
Adding a check over alias_id to prevent the unexpected behavior.
Fixes: 85dfdbfc13ea ("mailbox: cmdq: add multi-gce clocks support for mt8195")
Signed-off-by: Fei Shao <fshao@chromium.org>
Reviewed-by: Tzung-Bi Shih <tzungbi@google.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mailbox/mtk-cmdq-mailbox.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c index 4e9517efac29..2f6bb66341e4 100644 --- a/drivers/mailbox/mtk-cmdq-mailbox.c +++ b/drivers/mailbox/mtk-cmdq-mailbox.c @@ -570,7 +570,7 @@ static int cmdq_probe(struct platform_device *pdev) char clk_id[8]; alias_id = of_alias_get_id(node, clk_name); - if (alias_id < cmdq->gce_num) { + if (alias_id >= 0 && alias_id < cmdq->gce_num) { snprintf(clk_id, sizeof(clk_id), "%s%d", clk_name, alias_id); cmdq->clocks[alias_id].id = clk_id; cmdq->clocks[alias_id].clk = of_clk_get(node, 0); |