]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
selinux: fix error return code in policydb_read()
authorWei Yongjun <weiyongjun1@huawei.com>
Wed, 29 Apr 2020 07:30:53 +0000 (07:30 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Jun 2020 07:32:37 +0000 (09:32 +0200)
[ Upstream commit 4c09f8b6913a779ca0c70ea8058bf21537eebb3b ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
security/selinux/ss/policydb.c

index c21b922e5ebec1c851c74c22d43e17c39ff0c4e8..1a4f74e7a26716690ea14696eeb6624a42b6f3a7 100644 (file)
@@ -2504,6 +2504,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);