fix:Modify function security issues in mipidsi

Signed-off-by: jiaziyangmain <jiaziyang1@huawei.com>
This commit is contained in:
jiaziyangmain
2022-07-12 18:46:19 +08:00
parent 0ebb169779
commit 4259012f02
+16 -24
View File
@@ -336,13 +336,11 @@ static int32_t MipiDsiDevSetCfg(struct MipiDsiCntlr *cntlr, struct MipiCfg *arg)
HDF_LOGE("%s: [CopyFromUser] failed.", __func__);
return HDF_ERR_IO;
}
} else { /* kernel space */
if (memcpy_s(temp, size, arg, size) != EOK) {
OsalMemFree(temp);
temp = NULL;
HDF_LOGE("%s: [memcpy_s] failed.", __func__);
return HDF_ERR_IO;
}
} else {
OsalMemFree(temp);
temp = NULL;
HDF_LOGE("%s: illegal user space address.", __func__);
return HDF_FAILURE;
}
ret = MipiDsiCntlrSetCfg(cntlr, temp);
@@ -387,13 +385,11 @@ int32_t MipiDsiDevSetCmd(struct MipiDsiCntlr *cntlr, struct DsiCmdDesc *arg)
HDF_LOGE("%s: [CopyFromUser] failed.", __func__);
return HDF_ERR_IO;
}
} else { /* kernel space */
if (memcpy_s(temp, size, arg, size) != EOK) {
OsalMemFree(temp);
temp = NULL;
HDF_LOGE("%s: [memcpy_s] failed.", __func__);
return HDF_ERR_IO;
}
} else {
OsalMemFree(temp);
temp = NULL;
HDF_LOGE("%s: illegal user space address.", __func__);
return HDF_FAILURE;
}
ret = MipiDsiCntlrTx(cntlr, temp);
@@ -414,11 +410,9 @@ int32_t MipiDsiDevCmdCopyFromUser(GetDsiCmdDescTag *arg, GetDsiCmdDescTag *temp,
HDF_LOGE("%s: [CopyFromUser] failed.", __func__);
return HDF_ERR_IO;
}
} else { /* kernel space */
if (memcpy_s(temp, *size, arg, *size) != EOK) {
HDF_LOGE("%s: [memcpy_s] failed.", __func__);
return HDF_ERR_IO;
}
} else {
HDF_LOGE("%s: illegal user space address.", __func__);
return HDF_FAILURE;
}
return HDF_SUCCESS;
}
@@ -434,11 +428,9 @@ int32_t MipiDsiDevCmdCopyToUser(GetDsiCmdDescTag *arg, GetDsiCmdDescTag *temp, u
HDF_LOGE("%s: [CopyToUser] failed.", __func__);
return HDF_ERR_IO;
}
} else { /* kernel space */
if (memcpy_s(arg, *size, temp, *size) != EOK) {
HDF_LOGE("%s: [memcpy_s] failed.", __func__);
return HDF_ERR_IO;
}
} else {
HDF_LOGE("%s: illegal user space address.", __func__);
return HDF_FAILURE;
}
return HDF_SUCCESS;
}