diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2018-05-07 16:39:03 +0300 |
---|---|---|
committer | John Johansen <john.johansen@canonical.com> | 2018-06-07 01:50:40 -0700 |
commit | 5d8779a5cdda5530d5706586638a5cf0ac5bd8a3 (patch) | |
tree | a0e6052d3fc644c4b7f8ab954f6e442d2866be8b /security/apparmor | |
parent | 38125c2c2beb3c770d8fcdbcd846bd95938866d3 (diff) | |
download | linux-next-5d8779a5cdda5530d5706586638a5cf0ac5bd8a3.tar.gz |
apparmor: Convert to use match_string() helper
The new helper returns index of the matching string in an array.
We are going to use it here.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Jay Freyensee <why2jjj.linux@gmail.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
Diffstat (limited to 'security/apparmor')
-rw-r--r-- | security/apparmor/lsm.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c index 7866161f685b..8299a5d13fee 100644 --- a/security/apparmor/lsm.c +++ b/security/apparmor/lsm.c @@ -1391,14 +1391,12 @@ static int param_set_audit(const char *val, const struct kernel_param *kp) if (apparmor_initialized && !policy_admin_capable(NULL)) return -EPERM; - for (i = 0; i < AUDIT_MAX_INDEX; i++) { - if (strcmp(val, audit_mode_names[i]) == 0) { - aa_g_audit = i; - return 0; - } - } + i = match_string(audit_mode_names, AUDIT_MAX_INDEX, val); + if (i < 0) + return -EINVAL; - return -EINVAL; + aa_g_audit = i; + return 0; } static int param_get_mode(char *buffer, const struct kernel_param *kp) @@ -1422,14 +1420,13 @@ static int param_set_mode(const char *val, const struct kernel_param *kp) if (apparmor_initialized && !policy_admin_capable(NULL)) return -EPERM; - for (i = 0; i < APPARMOR_MODE_NAMES_MAX_INDEX; i++) { - if (strcmp(val, aa_profile_mode_names[i]) == 0) { - aa_g_profile_mode = i; - return 0; - } - } + i = match_string(aa_profile_mode_names, APPARMOR_MODE_NAMES_MAX_INDEX, + val); + if (i < 0) + return -EINVAL; - return -EINVAL; + aa_g_profile_mode = i; + return 0; } /* |