Commit d27c6bc9 authored by Aaro Koskinen's avatar Aaro Koskinen Committed by Greg Kroah-Hartman

staging: xgifb: check and report invalid option values

Check option values with kstrtoul(). This will also eliminate some
checkpatch warnings about simple_strtoul() usage.
Signed-off-by: default avatarAaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7b0a95f8
...@@ -1933,6 +1933,17 @@ static void XGIfb_get_VB_type(void) ...@@ -1933,6 +1933,17 @@ static void XGIfb_get_VB_type(void)
} }
} }
static int __init xgifb_optval(char *fullopt, int validx)
{
unsigned long lres;
if (kstrtoul(fullopt + validx, 0, &lres) < 0 || lres > INT_MAX) {
pr_err("xgifb: invalid value for option: %s\n", fullopt);
return 0;
}
return lres;
}
static int __init XGIfb_setup(char *options) static int __init XGIfb_setup(char *options)
{ {
char *this_opt; char *this_opt;
...@@ -1950,23 +1961,19 @@ static int __init XGIfb_setup(char *options) ...@@ -1950,23 +1961,19 @@ static int __init XGIfb_setup(char *options)
if (!strncmp(this_opt, "mode:", 5)) { if (!strncmp(this_opt, "mode:", 5)) {
XGIfb_search_mode(this_opt + 5); XGIfb_search_mode(this_opt + 5);
} else if (!strncmp(this_opt, "vesa:", 5)) { } else if (!strncmp(this_opt, "vesa:", 5)) {
XGIfb_search_vesamode(simple_strtoul( XGIfb_search_vesamode(xgifb_optval(this_opt, 5));
this_opt + 5, NULL, 0));
} else if (!strncmp(this_opt, "vrate:", 6)) { } else if (!strncmp(this_opt, "vrate:", 6)) {
xgi_video_info.refresh_rate = simple_strtoul( xgi_video_info.refresh_rate = xgifb_optval(this_opt, 6);
this_opt + 6, NULL, 0);
} else if (!strncmp(this_opt, "rate:", 5)) { } else if (!strncmp(this_opt, "rate:", 5)) {
xgi_video_info.refresh_rate = simple_strtoul( xgi_video_info.refresh_rate = xgifb_optval(this_opt, 5);
this_opt + 5, NULL, 0);
} else if (!strncmp(this_opt, "crt1off", 7)) { } else if (!strncmp(this_opt, "crt1off", 7)) {
XGIfb_crt1off = 1; XGIfb_crt1off = 1;
} else if (!strncmp(this_opt, "filter:", 7)) { } else if (!strncmp(this_opt, "filter:", 7)) {
filter = (int)simple_strtoul(this_opt + 7, NULL, 0); filter = xgifb_optval(this_opt, 7);
} else if (!strncmp(this_opt, "forcecrt2type:", 14)) { } else if (!strncmp(this_opt, "forcecrt2type:", 14)) {
XGIfb_search_crt2type(this_opt + 14); XGIfb_search_crt2type(this_opt + 14);
} else if (!strncmp(this_opt, "forcecrt1:", 10)) { } else if (!strncmp(this_opt, "forcecrt1:", 10)) {
XGIfb_forcecrt1 = (int)simple_strtoul( XGIfb_forcecrt1 = xgifb_optval(this_opt, 10);
this_opt + 10, NULL, 0);
} else if (!strncmp(this_opt, "tvmode:", 7)) { } else if (!strncmp(this_opt, "tvmode:", 7)) {
XGIfb_search_tvstd(this_opt + 7); XGIfb_search_tvstd(this_opt + 7);
} else if (!strncmp(this_opt, "tvstandard:", 11)) { } else if (!strncmp(this_opt, "tvstandard:", 11)) {
...@@ -1978,8 +1985,7 @@ static int __init XGIfb_setup(char *options) ...@@ -1978,8 +1985,7 @@ static int __init XGIfb_setup(char *options)
} else if (!strncmp(this_opt, "noypan", 6)) { } else if (!strncmp(this_opt, "noypan", 6)) {
XGIfb_ypan = 0; XGIfb_ypan = 0;
} else if (!strncmp(this_opt, "userom:", 7)) { } else if (!strncmp(this_opt, "userom:", 7)) {
XGIfb_userom = (int)simple_strtoul( XGIfb_userom = xgifb_optval(this_opt, 7);
this_opt + 7, NULL, 0);
} else { } else {
XGIfb_search_mode(this_opt); XGIfb_search_mode(this_opt);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment