diff mbox series

[2/2] ima: simplify function process_buffer_measurement

Message ID 20200414114850.98622-3-tianjia.zhang@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series Simplify the implementation of some functions in IMA | expand

Commit Message

tianjia.zhang April 14, 2020, 11:48 a.m. UTC
Remove duplicate judgment code to make it more suitable for linux
code style.

Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
---
 security/integrity/ima/ima_main.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Lakshmi Ramasubramanian April 14, 2020, 3:18 p.m. UTC | #1
On 4/14/20 4:48 AM, Tianjia Zhang wrote:

> Remove duplicate judgment code to make it more suitable for linux
> code style.
> 
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> ---
>   security/integrity/ima/ima_main.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
> index 9d0abedeae77..55cbbe97ce6e 100644
> --- a/security/integrity/ima/ima_main.c
> +++ b/security/integrity/ima/ima_main.c
> @@ -750,15 +750,15 @@ void process_buffer_measurement(const void *buf, int size,
>   		goto out;
>   
>   	ret = ima_store_template(entry, violation, NULL, buf, pcr);
> -
> -	if (ret < 0)
> -		ima_free_template_entry(entry);
> -
> -out:
>   	if (ret < 0)
> -		pr_devel("%s: failed, result: %d\n", __func__, ret);
> +		goto out_free_entry;
>   
>   	return;
> +
> +out_free_entry:
> +	ima_free_template_entry(entry);
> +out:
> +	pr_devel("%s: failed, result: %d\n", __func__, ret);
>   }

Reviewed-by: Lakshmi Ramasubramanian <nramas@linux.microsoft.com>
diff mbox series

Patch

diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 9d0abedeae77..55cbbe97ce6e 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -750,15 +750,15 @@  void process_buffer_measurement(const void *buf, int size,
 		goto out;
 
 	ret = ima_store_template(entry, violation, NULL, buf, pcr);
-
-	if (ret < 0)
-		ima_free_template_entry(entry);
-
-out:
 	if (ret < 0)
-		pr_devel("%s: failed, result: %d\n", __func__, ret);
+		goto out_free_entry;
 
 	return;
+
+out_free_entry:
+	ima_free_template_entry(entry);
+out:
+	pr_devel("%s: failed, result: %d\n", __func__, ret);
 }
 
 /**