tee-supplicant: fix uninit data access if stat() fails
do_mkdir() shall not rely on 'st' struct fields in case
stat() call returns error.
Signed-off-by: Jari Nippula <jari.nippula@tii.ae>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
diff --git a/tee-supplicant/src/tee_supp_fs.c b/tee-supplicant/src/tee_supp_fs.c
index 187a1db..5b517a0 100644
--- a/tee-supplicant/src/tee_supp_fs.c
+++ b/tee-supplicant/src/tee_supp_fs.c
@@ -105,7 +105,7 @@
if (mkdir(path, mode) != 0 && errno != EEXIST)
return -1;
- if (stat(path, &st) != 0 && !S_ISDIR(st.st_mode))
+ if (stat(path, &st) != 0 || !S_ISDIR(st.st_mode))
return -1;
return 0;