aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Gautier <yann.gautier@foss.st.com>2021-03-10 14:07:34 +0100
committerYann Gautier <yann.gautier@foss.st.com>2021-04-29 17:57:47 +0200
commitf714ca80b8e3dc4e953b8728fc7b9457094b2a12 (patch)
tree2606da2d96777854931f3390e6d66961483eceb2
parent6794378d2e955d2bf378ff2aa726a29d5884dc1f (diff)
downloadtrusted-firmware-a-f714ca80b8e3dc4e953b8728fc7b9457094b2a12.tar.gz
plat/st: do not rely on tainted value for dt property length
To compare the "okay" string of a property, strncmp is used but with the length given by fdt_getprop. This len value is reported as tainted by Coverity [1]. We just can use strlen("okay") which is a known value to compare the 2 strings. [1] https://scan4.coverity.com/reports.htm#v51972/p11439/fileInstanceId=96515154&defectInstanceId=14219121&mergedDefectId=342997 Signed-off-by: Yann Gautier <yann.gautier@foss.st.com> Change-Id: Ic8fb6ccf3126a37df615e433eb028861812015da
-rw-r--r--plat/st/common/stm32mp_dt.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/plat/st/common/stm32mp_dt.c b/plat/st/common/stm32mp_dt.c
index 391e5f0547..4f130ce20c 100644
--- a/plat/st/common/stm32mp_dt.c
+++ b/plat/st/common/stm32mp_dt.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2017-2021, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -72,21 +72,20 @@ bool fdt_check_node(int node)
uint8_t fdt_get_status(int node)
{
uint8_t status = DT_DISABLED;
- int len;
const char *cchar;
- cchar = fdt_getprop(fdt, node, "status", &len);
+ cchar = fdt_getprop(fdt, node, "status", NULL);
if ((cchar == NULL) ||
- (strncmp(cchar, "okay", (size_t)len) == 0)) {
+ (strncmp(cchar, "okay", strlen("okay")) == 0)) {
status |= DT_NON_SECURE;
}
- cchar = fdt_getprop(fdt, node, "secure-status", &len);
+ cchar = fdt_getprop(fdt, node, "secure-status", NULL);
if (cchar == NULL) {
if (status == DT_NON_SECURE) {
status |= DT_SECURE;
}
- } else if (strncmp(cchar, "okay", (size_t)len) == 0) {
+ } else if (strncmp(cchar, "okay", strlen("okay")) == 0) {
status |= DT_SECURE;
}