selinux: fix error return code in policydb_read()
authorWei Yongjun <weiyongjun1@huawei.com>
Wed, 29 Apr 2020 07:30:53 +0000 (07:30 +0000)
committerPaul Moore <paul@paul-moore.com>
Fri, 1 May 2020 19:02:14 +0000 (15:02 -0400)
Fix to return negative error code -ENOMEM from the kvcalloc() error
handling case instead of 0, as done elsewhere in this function.

Fixes: acdf52d97f82 ("selinux: convert to kvmalloc")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/ss/policydb.c

index 1c00415..a42369d 100644 (file)
@@ -2638,6 +2638,7 @@ int policydb_read(struct policydb *p, void *fp)
        if (rc)
                goto bad;
 
+       rc = -ENOMEM;
        p->type_attr_map_array = kvcalloc(p->p_types.nprim,
                                          sizeof(*p->type_attr_map_array),
                                          GFP_KERNEL);