Skip to content

Commit

Permalink
kernel/auditfilter.c: replace count*size kmalloc by kcalloc
Browse files Browse the repository at this point in the history
kcalloc manages count*sizeof overflow.

Signed-off-by: Fabian Frederick <[email protected]>
Cc: Eric Paris <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Fabian Frederick authored and torvalds committed Aug 7, 2014
1 parent 85417ae commit bab5e2d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/auditfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static inline struct audit_entry *audit_init_entry(u32 field_count)
if (unlikely(!entry))
return NULL;

fields = kzalloc(sizeof(*fields) * field_count, GFP_KERNEL);
fields = kcalloc(field_count, sizeof(*fields), GFP_KERNEL);
if (unlikely(!fields)) {
kfree(entry);
return NULL;
Expand Down Expand Up @@ -160,7 +160,7 @@ static __u32 *classes[AUDIT_SYSCALL_CLASSES];

int __init audit_register_class(int class, unsigned *list)
{
__u32 *p = kzalloc(AUDIT_BITMASK_SIZE * sizeof(__u32), GFP_KERNEL);
__u32 *p = kcalloc(AUDIT_BITMASK_SIZE, sizeof(__u32), GFP_KERNEL);
if (!p)
return -ENOMEM;
while (*list != ~0U) {
Expand Down

0 comments on commit bab5e2d

Please sign in to comment.