[PATCH v2 14/16] sandbox: Silence coverity warning in state_read_file()

Simon Glass sjg at chromium.org
Fri May 14 03:39:30 CEST 2021


In this case the value seems save to pass to os_free(). Add a comment.

Signed-off-by: Simon Glass <sjg at chromium.org>
Reported-by: Coverity (CID: 165109)
---

Changes in v2:
- Add a standard comment instead of a Coverity annotation

 arch/sandbox/cpu/state.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/sandbox/cpu/state.c b/arch/sandbox/cpu/state.c
index f63cfd38ee4..a4d99bade41 100644
--- a/arch/sandbox/cpu/state.c
+++ b/arch/sandbox/cpu/state.c
@@ -78,6 +78,10 @@ static int state_read_file(struct sandbox_state *state, const char *fname)
 err_read:
 	os_close(fd);
 err_open:
+	/*
+	 * tainted scalar, since size is obtained from the file. But we can rely
+	 * on os_malloc() to handle invalid values.
+	 */
 	os_free(state->state_fdt);
 	state->state_fdt = NULL;
 
-- 
2.31.1.751.gd2f1c929bd-goog



More information about the U-Boot mailing list