Skip to content

Commit 77563f3

Browse files
ligongwei-qmpcmoore
authored andcommitted
audit: Use kzalloc() instead of kmalloc()/memset() in audit_krule_to_data()
Replace kmalloc+memset by kzalloc for better readability and simplicity. This addresses the warning below: WARNING: kzalloc should be used for data, instead of kmalloc/memset Signed-off-by: Gongwei Li <ligongwei@kylinos.cn> [PM: subject and description tweaks] Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 4f7b54e commit 77563f3

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

kernel/auditfilter.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,9 @@ static struct audit_rule_data *audit_krule_to_data(struct audit_krule *krule)
638638
void *bufp;
639639
int i;
640640

641-
data = kmalloc(struct_size(data, buf, krule->buflen), GFP_KERNEL);
641+
data = kzalloc(struct_size(data, buf, krule->buflen), GFP_KERNEL);
642642
if (unlikely(!data))
643643
return NULL;
644-
memset(data, 0, sizeof(*data));
645644

646645
data->flags = krule->flags | krule->listnr;
647646
data->action = krule->action;

0 commit comments

Comments
 (0)