From e6e39e8b943205fad1b6f8abbe0f2b8315f7f3ea Mon Sep 17 00:00:00 2001 From: Satya Rama Aditya Pinapala Date: Mon, 9 Mar 2020 11:49:31 -0700 Subject: [PATCH] disp: msm: dsi: add check for invalid arguments in DSI clock control Check against the max clk_type and clk_state enumerations before to validate the type and state of DSI clocks to avoid Control Flow Integrity issues. Change-Id: Id53465c2b12debb1b356c0c91064eb017c2ca30d Signed-off-by: Satya Rama Aditya Pinapala --- msm/dsi/dsi_clk.h | 5 ++--- msm/dsi/dsi_clk_manager.c | 7 ++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/msm/dsi/dsi_clk.h b/msm/dsi/dsi_clk.h index 5c96ccf200..ff6bfb908f 100644 --- a/msm/dsi/dsi_clk.h +++ b/msm/dsi/dsi_clk.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */ #ifndef _DSI_CLK_H_ @@ -264,8 +264,7 @@ int dsi_display_link_clk_force_update_ctrl(void *handle); * * return: error code in case of failure or 0 for success. */ -int dsi_display_clk_ctrl(void *handle, - enum dsi_clk_type clk_type, enum dsi_clk_state clk_state); +int dsi_display_clk_ctrl(void *handle, u32 clk_type, u32 clk_state); /** * dsi_clk_set_link_frequencies() - set frequencies for link clks diff --git a/msm/dsi/dsi_clk_manager.c b/msm/dsi/dsi_clk_manager.c index 944cf40791..6801a79a1a 100644 --- a/msm/dsi/dsi_clk_manager.c +++ b/msm/dsi/dsi_clk_manager.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. */ #include @@ -1289,11 +1289,12 @@ int dsi_display_link_clk_force_update_ctrl(void *handle) } int dsi_display_clk_ctrl(void *handle, - enum dsi_clk_type clk_type, enum dsi_clk_state clk_state) + u32 clk_type, u32 clk_state) { int rc = 0; - if (!handle) { + if ((!handle) || (clk_type > DSI_ALL_CLKS) || + (clk_state > DSI_CLK_EARLY_GATE)) { DSI_ERR("Invalid arg\n"); return -EINVAL; }