From e034ee78e99385073c960c3cb0a8d8366d4d6951 Mon Sep 17 00:00:00 2001 From: Evoke Zhang Date: Mon, 27 Mar 2017 15:56:35 +0800 Subject: [PATCH] PD#138714: hdmitx: fix validate_vmode checking crash for invalid mode Change-Id: I2c57617316f24ac378143fc9e7ff66071b8dced1 Signed-off-by: Evoke Zhang --- .../vout/hdmitx/hdmi_common/hdmi_parameters.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/amlogic/media/vout/hdmitx/hdmi_common/hdmi_parameters.c b/drivers/amlogic/media/vout/hdmitx/hdmi_common/hdmi_parameters.c index 69b84f1ad13f..66201d21752f 100644 --- a/drivers/amlogic/media/vout/hdmitx/hdmi_common/hdmi_parameters.c +++ b/drivers/amlogic/media/vout/hdmitx/hdmi_common/hdmi_parameters.c @@ -1229,6 +1229,19 @@ static struct hdmi_format_para fmt_para_non_hdmi_fmt = { .vic = HDMI_Unknown, .name = "invalid", .sname = "invalid", + .hdmitx_vinfo = { + .name = "invalid", + .mode = VMODE_MAX, + .width = 1920, + .height = 1080, + .field_height = 1080, + .aspect_ratio_num = 16, + .aspect_ratio_den = 9, + .sync_duration_num = 60, + .sync_duration_den = 1, + .video_clk = 148500000, + .viu_color_fmt = COLOR_FMT_YUV444, + }, }; /* null mode is used for HDMI, such as current mode is 1080p24hz @@ -1489,12 +1502,14 @@ struct vinfo_s *hdmi_get_valid_vinfo(char *mode) /* the string of mode contains char NF */ memset(mode_, 0, sizeof(mode_)); - strncpy(mode_, mode, sizeof(mode_)); + strncpy(mode_, mode, strlen(mode)); for (i = 0; i < sizeof(mode_); i++) if (mode_[i] == 10) mode_[i] = 0; for (i = 0; all_fmt_paras[i]; i++) { + if (all_fmt_paras[i]->hdmitx_vinfo.mode == VMODE_MAX) + continue; if (strncmp(all_fmt_paras[i]->hdmitx_vinfo.name, mode_, strlen(mode_)) == 0) { info = &all_fmt_paras[i]->hdmitx_vinfo; -- 2.20.1