hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/security/integrity/ima/ima_template.c
....@@ -220,11 +220,11 @@
220220 }
221221
222222 if (fields && num_fields) {
223
- *fields = kmalloc_array(i, sizeof(*fields), GFP_KERNEL);
223
+ *fields = kmalloc_array(i, sizeof(**fields), GFP_KERNEL);
224224 if (*fields == NULL)
225225 return -ENOMEM;
226226
227
- memcpy(*fields, found_fields, i * sizeof(*fields));
227
+ memcpy(*fields, found_fields, i * sizeof(**fields));
228228 *num_fields = i;
229229 }
230230
....@@ -290,8 +290,11 @@
290290
291291 template_desc->name = "";
292292 template_desc->fmt = kstrdup(template_name, GFP_KERNEL);
293
- if (!template_desc->fmt)
293
+ if (!template_desc->fmt) {
294
+ kfree(template_desc);
295
+ template_desc = NULL;
294296 goto out;
297
+ }
295298
296299 spin_lock(&template_list);
297300 list_add_tail_rcu(&template_desc->list, &defined_templates);