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>
This commit is contained in:
Gongwei Li 2025-11-05 18:36:19 +08:00 committed by Paul Moore
parent 4f7b54e17e
commit 77563f3d47
1 changed files with 1 additions and 2 deletions

View File

@ -638,10 +638,9 @@ static struct audit_rule_data *audit_krule_to_data(struct audit_krule *krule)
void *bufp;
int i;
data = kmalloc(struct_size(data, buf, krule->buflen), GFP_KERNEL);
data = kzalloc(struct_size(data, buf, krule->buflen), GFP_KERNEL);
if (unlikely(!data))
return NULL;
memset(data, 0, sizeof(*data));
data->flags = krule->flags | krule->listnr;
data->action = krule->action;