@@ -2136,6 +2136,7 @@ static int semanage_direct_set_module_info(semanage_handle_t *sh,
char fn[PATH_MAX];
const char *path = NULL;
int enabled = 0;
+ semanage_module_info_t *modinfo_tmp = NULL;
semanage_module_key_t modkey;
ret = semanage_module_key_init(sh, &modkey);
@@ -2144,8 +2145,6 @@ static int semanage_direct_set_module_info(semanage_handle_t *sh,
goto cleanup;
}
- semanage_module_info_t *modinfo_tmp = NULL;
-
/* check transaction */
if (!sh->is_in_transaction) {
if (semanage_begin_transaction(sh) < 0) {
@@ -2316,6 +2315,8 @@ static int semanage_direct_list_all(semanage_handle_t *sh,
uint16_t priority = 0;
+ semanage_module_info_t *modinfo_tmp = NULL;
+
semanage_module_info_t modinfo;
ret = semanage_module_info_init(sh, &modinfo);
if (ret != 0) {
@@ -2323,8 +2324,6 @@ static int semanage_direct_list_all(semanage_handle_t *sh,
goto cleanup;
}
- semanage_module_info_t *modinfo_tmp = NULL;
-
if (sh->is_in_transaction) {
toplevel = semanage_path(SEMANAGE_TMP, SEMANAGE_MODULES);
} else {
In semanage_direct_set_module_info() and semanage_direct_list_all() functions, when modinfo_tmp variable gets initialized, a branch to "cleanup" label may have already been taken. This leads to this variable being possibly used uninitialized in these functions. This is reported by clang: direct_api.c:2491:41: error: variable 'modinfo_tmp' may be uninitialized when used here [-Werror,-Wconditional-uninitialized] ret = semanage_module_info_destroy(sh, modinfo_tmp); ^~~~~~~~~~~ direct_api.c:2334:2: note: variable 'modinfo_tmp' is declared here semanage_module_info_t *modinfo_tmp = NULL; ^ Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org> --- libsemanage/src/direct_api.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)