Message ID | 20200501195111.3335258-1-omosnace@redhat.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | selinux: fix return value on error in policydb_read() | expand |
On Fri, May 1, 2020 at 3:51 PM Ondrej Mosnacek <omosnace@redhat.com> wrote: > > The value of rc is still zero from the last assignment when the error > path is taken. Fix it by setting it to -ENOMEM before the > hashtab_create() call. > > Reported-by: Dan Carpenter <dan.carpenter@oracle.com> > Fixes: e67b2ec9f617 ("selinux: store role transitions in a hash table") > Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> > --- > security/selinux/ss/policydb.c | 1 + > 1 file changed, 1 insertion(+) Here I was just about to reply to your other patches that patch 2/4 looked fine to me but I was going to hold off on applying it until this patch came through :) Merged into selinux/next, thanks.
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index 1c0041576643..9f7ce3e037d1 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -2540,6 +2540,7 @@ int policydb_read(struct policydb *p, void *fp) goto bad; nel = le32_to_cpu(buf[0]); + rc = -ENOMEM; p->role_tr = hashtab_create(role_trans_hash, role_trans_cmp, nel); if (!p->role_tr) goto bad;
The value of rc is still zero from the last assignment when the error path is taken. Fix it by setting it to -ENOMEM before the hashtab_create() call. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Fixes: e67b2ec9f617 ("selinux: store role transitions in a hash table") Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> --- security/selinux/ss/policydb.c | 1 + 1 file changed, 1 insertion(+)