ima: initialize only required template
IMA uses only one template. This patch initializes only required template to avoid unnecessary memory allocations. Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com> Reviewed-by: Roberto Sassu <roberto.sassu@polito.it> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
This commit is contained in:
parent
17f4bad3ab
commit
b4148db517
1 changed files with 4 additions and 24 deletions
|
@ -152,24 +152,6 @@ out:
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __init init_defined_templates(void)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
/* Init defined templates. */
|
|
||||||
for (i = 0; i < ARRAY_SIZE(defined_templates); i++) {
|
|
||||||
struct ima_template_desc *template = &defined_templates[i];
|
|
||||||
|
|
||||||
result = template_desc_init_fields(template->fmt,
|
|
||||||
&(template->fields),
|
|
||||||
&(template->num_fields));
|
|
||||||
if (result < 0)
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ima_template_desc *ima_template_desc_current(void)
|
struct ima_template_desc *ima_template_desc_current(void)
|
||||||
{
|
{
|
||||||
if (!ima_template)
|
if (!ima_template)
|
||||||
|
@ -180,11 +162,9 @@ struct ima_template_desc *ima_template_desc_current(void)
|
||||||
|
|
||||||
int __init ima_init_template(void)
|
int __init ima_init_template(void)
|
||||||
{
|
{
|
||||||
int result;
|
struct ima_template_desc *template = ima_template_desc_current();
|
||||||
|
|
||||||
result = init_defined_templates();
|
return template_desc_init_fields(template->fmt,
|
||||||
if (result < 0)
|
&(template->fields),
|
||||||
return result;
|
&(template->num_fields));
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue