Skip to content

Commit

Permalink
params: don't ignore the rest of cmdline if parse_one() fails
Browse files Browse the repository at this point in the history
parse_args() just aborts after it hits an error, so other args
at the same initcall level are simply ignored. This can lead to
other hard-to-understand problems, for example my testing machine
panics during the boot if I pass "locktorture.verbose=true".

Change parse_args() to save the err code for return and continue.

Signed-off-by: Oleg Nesterov <[email protected]>
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
oleg-nesterov authored and rustyrussell committed Aug 26, 2015
1 parent 5cfb203 commit 74b22c4
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions kernel/params.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ char *parse_args(const char *doing,
int (*unknown)(char *param, char *val,
const char *doing, void *arg))
{
char *param, *val;
char *param, *val, *err = NULL;

/* Chew leading spaces */
args = skip_spaces(args);
Expand All @@ -238,7 +238,7 @@ char *parse_args(const char *doing,
args = next_arg(args, &param, &val);
/* Stop at -- */
if (!val && strcmp(param, "--") == 0)
return args;
return err ?: args;
irq_was_disabled = irqs_disabled();
ret = parse_one(param, val, doing, params, num,
min_level, max_level, arg, unknown);
Expand All @@ -247,24 +247,25 @@ char *parse_args(const char *doing,
doing, param);

switch (ret) {
case 0:
continue;
case -ENOENT:
pr_err("%s: Unknown parameter `%s'\n", doing, param);
return ERR_PTR(ret);
break;
case -ENOSPC:
pr_err("%s: `%s' too large for parameter `%s'\n",
doing, val ?: "", param);
return ERR_PTR(ret);
case 0:
break;
default:
pr_err("%s: `%s' invalid for parameter `%s'\n",
doing, val ?: "", param);
return ERR_PTR(ret);
break;
}

err = ERR_PTR(ret);
}

/* All parsed OK. */
return NULL;
return err;
}

/* Lazy bastard, eh? */
Expand Down

0 comments on commit 74b22c4

Please sign in to comment.