libsepol: cil: check cil_fill_list return value

cil_gen_default() and cil_gen_defaultrange() call cil_fill_list()
without checking its return value. If it failed, propagate the return
value to the caller.

This issue has been found using clang's static analyzer. It reported
"warning: Value stored to 'rc' is never read" four times.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
This commit is contained in:
Nicolas Iooss 2017-04-11 23:45:59 +02:00 committed by Stephen Smalley
parent ea175157dd
commit b63eb892f9
1 changed files with 6 additions and 2 deletions

View File

@ -5592,9 +5592,11 @@ int cil_gen_default(struct cil_tree_node *parse_current, struct cil_tree_node *a
if (parse_current->next->cl_head == NULL) { if (parse_current->next->cl_head == NULL) {
cil_list_init(&def->class_strs, CIL_CLASS); cil_list_init(&def->class_strs, CIL_CLASS);
cil_list_append(def->class_strs, CIL_STRING, parse_current->next->data); cil_list_append(def->class_strs, CIL_STRING, parse_current->next->data);
rc = SEPOL_OK;
} else { } else {
rc = cil_fill_list(parse_current->next->cl_head, CIL_CLASS, &def->class_strs); rc = cil_fill_list(parse_current->next->cl_head, CIL_CLASS, &def->class_strs);
if (rc != SEPOL_OK) {
goto exit;
}
} }
object = parse_current->next->next->data; object = parse_current->next->next->data;
@ -5657,9 +5659,11 @@ int cil_gen_defaultrange(struct cil_tree_node *parse_current, struct cil_tree_no
if (parse_current->next->cl_head == NULL) { if (parse_current->next->cl_head == NULL) {
cil_list_init(&def->class_strs, CIL_CLASS); cil_list_init(&def->class_strs, CIL_CLASS);
cil_list_append(def->class_strs, CIL_STRING, parse_current->next->data); cil_list_append(def->class_strs, CIL_STRING, parse_current->next->data);
rc = SEPOL_OK;
} else { } else {
rc = cil_fill_list(parse_current->next->cl_head, CIL_CLASS, &def->class_strs); rc = cil_fill_list(parse_current->next->cl_head, CIL_CLASS, &def->class_strs);
if (rc != SEPOL_OK) {
goto exit;
}
} }
object = parse_current->next->next->data; object = parse_current->next->next->data;