hdmitx: Coverity(upgraded) defect cleanup: hdmitx [1/1]

PD#SWPL-16574

Problem:
Coverity(upgraded) defect cleanup: hdmitx

Solution:
Modify code according to coverity

Verify:
verify on the board of U212

Change-Id: Iac69fb896dd22b38ae56b58701d6fd26aefe958c
Signed-off-by: Zhengrong Zhu <zhengrong.zhu@amlogic.com>
This commit is contained in:
Zhengrong.Zhu
2019-11-22 19:16:30 +08:00
committed by Chris KIM
parent 313dac7573
commit 6c9ae88176
2 changed files with 10 additions and 7 deletions

View File

@@ -1855,7 +1855,7 @@ static int hdmitx_edid_search_IEEEOUI(char *buf)
{
int i;
for (i = 0; i < 0x180; i++) {
for (i = 0; i < 0x180 - 2; i++) {
if ((buf[i] == 0x03) && (buf[i+1] == 0x0c) &&
(buf[i+2] == 0x00))
return 1;

View File

@@ -4657,18 +4657,19 @@ static void hdmitx_fmt_attr(struct hdmitx_dev *hdev)
(hdev->para->cs == COLORSPACE_RESERVED)) {
strcpy(hdev->fmt_attr, "default");
} else {
memset(hdev->fmt_attr, 0, sizeof(hdev->fmt_attr));
switch (hdev->para->cs) {
case COLORSPACE_RGB444:
memcpy(hdev->fmt_attr, "rgb,", 4);
memcpy(hdev->fmt_attr, "rgb,", 5);
break;
case COLORSPACE_YUV422:
memcpy(hdev->fmt_attr, "422,", 4);
memcpy(hdev->fmt_attr, "422,", 5);
break;
case COLORSPACE_YUV444:
memcpy(hdev->fmt_attr, "444,", 4);
memcpy(hdev->fmt_attr, "444,", 5);
break;
case COLORSPACE_YUV420:
memcpy(hdev->fmt_attr, "420,", 4);
memcpy(hdev->fmt_attr, "420,", 5);
break;
default:
break;
@@ -5501,8 +5502,10 @@ static void check_hdmiuboot_attr(char *token)
}
for (i = 0; cd[i] != NULL; i++) {
if (strstr(token, cd[i])) {
if (strlen(cd[i]) < (sizeof(attr) - strlen(attr)))
strncat(attr, cd[i], strlen(cd[i]));
if (strlen(cd[i]) < sizeof(attr))
if (strlen(cd[i]) <
(sizeof(attr) - strlen(attr)))
strncat(attr, cd[i], strlen(cd[i]));
strncpy(hdmitx_device.fmt_attr, attr,
sizeof(hdmitx_device.fmt_attr));
hdmitx_device.fmt_attr[15] = '\0';