summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorYisheng Xie <xieyisheng1@huawei.com>2018-05-21 19:58:02 +0800
committerMimi Zohar <zohar@linux.vnet.ibm.com>2018-05-31 10:11:58 -0400
commitb4df86085af9d3f456bed8245cede7c4413dcf83 (patch)
treebf74ddc01902c32c84677d5b4321b5561f58746d /security
parent6f0911a666d1f99ff72e7848ddee36af7bbce050 (diff)
downloadlinux-b4df86085af9d3f456bed8245cede7c4413dcf83.tar.gz
linux-b4df86085af9d3f456bed8245cede7c4413dcf83.tar.bz2
linux-b4df86085af9d3f456bed8245cede7c4413dcf83.zip
ima: use match_string() helper
match_string() returns the index of an array for a matching string, which can be used intead of open coded variant. Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Diffstat (limited to 'security')
-rw-r--r--security/integrity/ima/ima_main.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 83f84928ad76..dca44cf7838e 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -59,14 +59,11 @@ static int __init hash_setup(char *str)
goto out;
}
- for (i = 0; i < HASH_ALGO__LAST; i++) {
- if (strcmp(str, hash_algo_name[i]) == 0) {
- ima_hash_algo = i;
- break;
- }
- }
- if (i == HASH_ALGO__LAST)
+ i = match_string(hash_algo_name, HASH_ALGO__LAST, str);
+ if (i < 0)
return 1;
+
+ ima_hash_algo = i;
out:
hash_setup_done = 1;
return 1;