]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
audit: Use kzalloc() instead of kmalloc()/memset() in audit_krule_to_data()
authorGongwei Li <ligongwei@kylinos.cn>
Wed, 5 Nov 2025 10:36:19 +0000 (18:36 +0800)
committerPaul Moore <paul@paul-moore.com>
Fri, 7 Nov 2025 21:38:34 +0000 (16:38 -0500)
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>
kernel/auditfilter.c

index c401082d9b2506c1e226eb27eb4135232cfd60ee..6a86c0683b674dbde50f0d8a946a563bffc77d90 100644 (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;