diff options
author | Markus Elfring <elfring@users.sourceforge.net> | 2017-01-14 04:48:28 -0500 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2017-03-23 16:21:41 -0400 |
commit | f6076f704aa29679fdba114b0f60e71e0884840a (patch) | |
tree | 560732899393bb4362b014a81ec6eb04cf5ad4ae /security/selinux/ss/conditional.c | |
parent | e2f586bd83177d22072b275edd4b8b872daba924 (diff) |
selinux: Use kmalloc_array() in cond_init_bool_indexes()
* A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".
This issue was detected by using the Coccinelle software.
* Replace the specification of a data type by a pointer dereference
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/selinux/ss/conditional.c')
-rw-r--r-- | security/selinux/ss/conditional.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/security/selinux/ss/conditional.c b/security/selinux/ss/conditional.c index 34afeadd9e73..fcfab2635c11 100644 --- a/security/selinux/ss/conditional.c +++ b/security/selinux/ss/conditional.c | |||
@@ -176,8 +176,9 @@ void cond_policydb_destroy(struct policydb *p) | |||
176 | int cond_init_bool_indexes(struct policydb *p) | 176 | int cond_init_bool_indexes(struct policydb *p) |
177 | { | 177 | { |
178 | kfree(p->bool_val_to_struct); | 178 | kfree(p->bool_val_to_struct); |
179 | p->bool_val_to_struct = | 179 | p->bool_val_to_struct = kmalloc_array(p->p_bools.nprim, |
180 | kmalloc(p->p_bools.nprim * sizeof(struct cond_bool_datum *), GFP_KERNEL); | 180 | sizeof(*p->bool_val_to_struct), |
181 | GFP_KERNEL); | ||
181 | if (!p->bool_val_to_struct) | 182 | if (!p->bool_val_to_struct) |
182 | return -ENOMEM; | 183 | return -ENOMEM; |
183 | return 0; | 184 | return 0; |