lkml.org 
[lkml]   [2020]   [Jun]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] selinux: fix undefined return of cond_evaluate_expr
On Wed, Jun 17, 2020 at 8:40 AM <trix@redhat.com> wrote:
>
> From: Tom Rix <trix@redhat.com>
>
> clang static analysis reports an undefined return
>
> security/selinux/ss/conditional.c:79:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]
> return s[0];
> ^~~~~~~~~~~
>
> static int cond_evaluate_expr( ...
> {
> u32 i;
> int s[COND_EXPR_MAXDEPTH];
>
> for (i = 0; i < expr->len; i++)
> ...
>
> return s[0];
>
> When expr->len is 0, the loop which sets s[0] never runs.
>
> So return -1 if the loop never runs.
>
> Signed-off-by: Tom Rix <trix@redhat.com>

Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>

clang didn't complain about the similar pattern in
security/selinux/ss/services.c:constraint_expr_eval()?

\
 
 \ /
  Last update: 2020-06-17 15:59    [W:0.801 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site