From 77563f3d4704206c8f6626852365591aa4e0b779 Mon Sep 17 00:00:00 2001 From: Gongwei Li Date: Wed, 5 Nov 2025 18:36:19 +0800 Subject: [PATCH] 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 [PM: subject and description tweaks] Signed-off-by: Paul Moore --- kernel/auditfilter.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c index c401082d9b250..6a86c0683b674 100644 --- a/kernel/auditfilter.c +++ b/kernel/auditfilter.c @@ -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; -- 2.47.3