checkpolicy: check before potential NULL dereference

policy_define.c: In function ‘define_te_avtab_extended_perms’:
    policy_define.c:1946:17: error: potential null pointer dereference [-Werror=null-dereference]
     1946 |         r->omit = omit;
          |                 ^

In the case of `r` being NULL, avrule_read_ioctls() would return
with its parameter `rangehead` being a pointer to NULL, which is
considered a failure in its caller `avrule_ioctl_ranges`.
So it is not necessary to alter the return value.

Found by GCC 11 with LTO enabled.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
This commit is contained in:
Christian Göttsche 2021-07-06 19:54:28 +02:00 committed by Nicolas Iooss
parent 7723180fa0
commit 5a10f05f53
No known key found for this signature in database
GPG Key ID: C191415F340DAAA0
1 changed files with 3 additions and 1 deletions

View File

@ -1943,7 +1943,9 @@ int avrule_read_ioctls(struct av_ioctl_range_list **rangehead)
} }
} }
r = *rangehead; r = *rangehead;
if (r) {
r->omit = omit; r->omit = omit;
}
return 0; return 0;
error: error:
yyerror("out of memory"); yyerror("out of memory");