Skip to content

Commit

Permalink
soc: imx: imx8m-blk-ctrl: off by one in imx8m_blk_ctrl_xlate()
Browse files Browse the repository at this point in the history
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 <dan.carpenter@oracle.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Shawn Guo <shawnguo@kernel.org>
  • Loading branch information
Dan Carpenter authored and Shawn Guo committed Oct 15, 2021
1 parent 926e57c commit 72949f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/soc/imx/imx8m-blk-ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 72949f7

Please sign in to comment.