From: Wei Yongjun Date: Wed, 29 Apr 2020 07:30:53 +0000 (+0000) Subject: selinux: fix error return code in policydb_read() X-Git-Tag: v5.7.5~232 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=dba89dee461f725841c069b577f87825c871bc5b;p=users%2Fdwmw2%2Flinux.git selinux: fix error return code in policydb_read() [ 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 Signed-off-by: Paul Moore Signed-off-by: Sasha Levin --- diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index c21b922e5ebec..1a4f74e7a2671 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -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);