From: Dan Carpenter Date: Mon, 11 Oct 2021 12:36:38 +0000 (+0300) Subject: soc: imx: imx8m-blk-ctrl: off by one in imx8m_blk_ctrl_xlate() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=72949f76565c9ea9f4231c977774a31d4713c386;p=linux.git soc: imx: imx8m-blk-ctrl: off by one in imx8m_blk_ctrl_xlate() The > comparison should be >= to prevent reading one element beyond the end of the array. The onecell_data->domains[] array is allocated in imx8m_blk_ctrl_probe() and it has "onecell_data->num_domains" elements. Fixes: 5b340e7813d4 ("soc: imx: add i.MX8M blk-ctrl driver") Signed-off-by: Dan Carpenter Reviewed-by: Lucas Stach Signed-off-by: Shawn Guo --- diff --git a/drivers/soc/imx/imx8m-blk-ctrl.c b/drivers/soc/imx/imx8m-blk-ctrl.c index e172d295c4412..519b3651d1d96 100644 --- a/drivers/soc/imx/imx8m-blk-ctrl.c +++ b/drivers/soc/imx/imx8m-blk-ctrl.c @@ -139,7 +139,7 @@ imx8m_blk_ctrl_xlate(struct of_phandle_args *args, void *data) unsigned int index = args->args[0]; if (args->args_count != 1 || - index > onecell_data->num_domains) + index >= onecell_data->num_domains) return ERR_PTR(-EINVAL); return onecell_data->domains[index];