selinux: minor tweaks to selinux_add_opt()
Two minor edits to selinux_add_opt(): use "sizeof(*ptr)" instead of "sizeof(type)" in the kzalloc() call, and rename the "Einval" jump target to "err" for the sake of consistency. Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
parent
2e08df3c7c
commit
6cd9d4b978
@ -972,14 +972,14 @@ static int selinux_add_opt(int token, const char *s, void **mnt_opts)
|
|||||||
struct selinux_mnt_opts *opts = *mnt_opts;
|
struct selinux_mnt_opts *opts = *mnt_opts;
|
||||||
bool is_alloc_opts = false;
|
bool is_alloc_opts = false;
|
||||||
|
|
||||||
if (token == Opt_seclabel) /* eaten and completely ignored */
|
if (token == Opt_seclabel)
|
||||||
|
/* eaten and completely ignored */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!s)
|
if (!s)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (!opts) {
|
if (!opts) {
|
||||||
opts = kzalloc(sizeof(struct selinux_mnt_opts), GFP_KERNEL);
|
opts = kzalloc(sizeof(*opts), GFP_KERNEL);
|
||||||
if (!opts)
|
if (!opts)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
*mnt_opts = opts;
|
*mnt_opts = opts;
|
||||||
@ -989,27 +989,29 @@ static int selinux_add_opt(int token, const char *s, void **mnt_opts)
|
|||||||
switch (token) {
|
switch (token) {
|
||||||
case Opt_context:
|
case Opt_context:
|
||||||
if (opts->context || opts->defcontext)
|
if (opts->context || opts->defcontext)
|
||||||
goto Einval;
|
goto err;
|
||||||
opts->context = s;
|
opts->context = s;
|
||||||
break;
|
break;
|
||||||
case Opt_fscontext:
|
case Opt_fscontext:
|
||||||
if (opts->fscontext)
|
if (opts->fscontext)
|
||||||
goto Einval;
|
goto err;
|
||||||
opts->fscontext = s;
|
opts->fscontext = s;
|
||||||
break;
|
break;
|
||||||
case Opt_rootcontext:
|
case Opt_rootcontext:
|
||||||
if (opts->rootcontext)
|
if (opts->rootcontext)
|
||||||
goto Einval;
|
goto err;
|
||||||
opts->rootcontext = s;
|
opts->rootcontext = s;
|
||||||
break;
|
break;
|
||||||
case Opt_defcontext:
|
case Opt_defcontext:
|
||||||
if (opts->context || opts->defcontext)
|
if (opts->context || opts->defcontext)
|
||||||
goto Einval;
|
goto err;
|
||||||
opts->defcontext = s;
|
opts->defcontext = s;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
Einval:
|
|
||||||
|
err:
|
||||||
if (is_alloc_opts) {
|
if (is_alloc_opts) {
|
||||||
kfree(opts);
|
kfree(opts);
|
||||||
*mnt_opts = NULL;
|
*mnt_opts = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user