Skip to content

Commit 2a421e6

Browse files
stephensmalleygregkh
authored andcommitted
selinux: switch two allocations to use kzalloc_objs()
[ Upstream commit cf6a513 ] These were the only two allocations in the policy loading logic that were not already using kzalloc_objs() for the policy data structures. Fix these to be consistent with the rest and to protect against ill-formed policy. Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com> Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ff4a5b1 commit 2a421e6

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

security/selinux/ss/conditional.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ void cond_policydb_destroy(struct policydb *p)
166166
int cond_init_bool_indexes(struct policydb *p)
167167
{
168168
kfree(p->bool_val_to_struct);
169-
p->bool_val_to_struct = kmalloc_array(p->p_bools.nprim,
170-
sizeof(*p->bool_val_to_struct),
171-
GFP_KERNEL);
169+
p->bool_val_to_struct = kcalloc(p->p_bools.nprim,
170+
sizeof(*p->bool_val_to_struct),
171+
GFP_KERNEL);
172172
if (!p->bool_val_to_struct)
173173
return -ENOMEM;
174174
return 0;
@@ -714,9 +714,9 @@ static int duplicate_policydb_bools(struct policydb *newdb,
714714
struct cond_bool_datum **cond_bool_array;
715715
int rc;
716716

717-
cond_bool_array = kmalloc_array(orig->p_bools.nprim,
718-
sizeof(*orig->bool_val_to_struct),
719-
GFP_KERNEL);
717+
cond_bool_array = kcalloc(orig->p_bools.nprim,
718+
sizeof(*orig->bool_val_to_struct),
719+
GFP_KERNEL);
720720
if (!cond_bool_array)
721721
return -ENOMEM;
722722

0 commit comments

Comments
 (0)