[PATCH 02/12] globalvar: fix uninitialized read of variable when no nvvars exist

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Sep 30 03:19:55 EDT 2020


When there are no nvvars, the function returns an uninitialized ret,
return 0 in this case instead.

Reported-by: clang-analyzer-10
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/globalvar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/globalvar.c b/common/globalvar.c
index 09479da548f6..904acb94d730 100644
--- a/common/globalvar.c
+++ b/common/globalvar.c
@@ -674,7 +674,7 @@ int nvvar_save(void)
 {
 	struct param_d *param;
 	const char *env = default_environment_path_get();
-	int ret;
+	int ret = 0;
 #define TMPDIR "/.env.tmp"
 	if (!nv_dirty || !env)
 		return 0;
-- 
2.28.0




More information about the barebox mailing list