From c782e34f45f1fd9318bd452b6fd880fc1529e2db Mon Sep 17 00:00:00 2001 From: "ruofei.zhao" Date: Mon, 11 Mar 2024 13:41:14 +0800 Subject: [PATCH] hdmitx: add null pointer judgment in boot_parameters [1/1] PD#SH-18773 PD#SWPL-160955 Problem: The boot_parameters parameter does not perform null pointer judgment, which will cause a crash Solution: add null pointer judgment in boot_parameters Verify: T7C SC2 Test: DRM-TX- Change-Id: Idd5fe05145ac07d1358293d26872bcf4a2bc5eda Signed-off-by: ruofei.zhao --- .../hdmitx_common/hdmitx_boot_parameters.c | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/drivers/media/vout/hdmitx_common/hdmitx_boot_parameters.c b/drivers/media/vout/hdmitx_common/hdmitx_boot_parameters.c index 7c99a6d1e..51c10cf4c 100644 --- a/drivers/media/vout/hdmitx_common/hdmitx_boot_parameters.c +++ b/drivers/media/vout/hdmitx_common/hdmitx_boot_parameters.c @@ -123,8 +123,15 @@ static int parse_hdmitx_boot_para(char *s) unsigned int token_len = 0; unsigned int token_offset = 0; unsigned int offset = 0; - int size = strlen(s); + int size = 0; + if (!s) { + memset(tx_params.color_attr, 0, sizeof(tx_params.color_attr)); + tx_params.init_state = 0; + return -EINVAL; + } + + size = strlen(s); memset(tx_params.color_attr, 0, sizeof(tx_params.color_attr)); tx_params.init_state = 0; @@ -154,6 +161,11 @@ __setup("hdmitx=", parse_hdmitx_boot_para); static int parse_hdmitx_fraction_rate(char *str) { + if (!str) { + tx_params.fraction_refreshrate = 1; + return -EINVAL; + } + if (strncmp("0", str, 1) == 0) tx_params.fraction_refreshrate = 0; else @@ -171,6 +183,11 @@ static int parse_hdmitx_hdr_priority(char *str) int err; u32 value; + if (!str) { + tx_params.hdr_mask = 0; + return -EINVAL; + } + err = kstrtou32(str, 10, &value); if (err) { HDMITX_ERROR("%s fail\n", __func__); @@ -188,6 +205,11 @@ __setup("hdr_priority=", parse_hdmitx_hdr_priority); static int parse_hdmitx_checksum(char *str) { + if (!str) { + pr_err("hdmitx_param:[checksum]=[%s]\n", tx_params.edid_chksum); + return -EINVAL; + } + snprintf(tx_params.edid_chksum, sizeof(tx_params.edid_chksum), "%s", str); pr_debug("hdmitx_param:[checksum]=[%s]\n", tx_params.edid_chksum); @@ -197,6 +219,11 @@ __setup("hdmichecksum=", parse_hdmitx_checksum); static int hdmitx_config_csc_en(char *str) { + if (!str) { + tx_params.config_csc = false; + return -EINVAL; + } + if (strncmp("1", str, 1) == 0) tx_params.config_csc = true; else @@ -204,13 +231,17 @@ static int hdmitx_config_csc_en(char *str) pr_debug("config_csc_en:[config_csc_en]=[%d]\n", tx_params.config_csc); return 0; } - __setup("config_csc_en=", hdmitx_config_csc_en); static int hdmitx_boot_edid_check(char *str) { int val = 0; + if (!str) { + tx_params.edid_check = 0; + return -EINVAL; + } + if ((strncmp("0", str, 1) == 0) || (strncmp("1", str, 1) == 0) || (strncmp("2", str, 1) == 0) || (strncmp("3", str, 1) == 0)) { val = str[0] - '0'; @@ -220,13 +251,17 @@ static int hdmitx_boot_edid_check(char *str) return 0; } - __setup("edid_check=", hdmitx_boot_edid_check); static int hdmitx_boot_dsc_policy(char *str) { unsigned int val = 0; + if (!str) { + tx_params.dsc_policy = 0; + return -EINVAL; + } + if ((strncmp("0", str, 1) == 0) || (strncmp("1", str, 1) == 0) || (strncmp("2", str, 1) == 0) ||