From: Michal Nazarewicz Date: Wed, 9 Jan 2013 09:17:47 +0000 (+0100) Subject: usb: gadget: FunctionFS: Use kstrtoul() X-Git-Tag: v3.9-rc1~126^2~43^2~42 X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=afd2e186bd7e58dc9d298ff5fb5a2fc30578867e;p=~emulex%2Finfiniband.git usb: gadget: FunctionFS: Use kstrtoul() kstrtoul() checks for overflow which simple_strtoul() does not pluss it has “*end == 0” check in it as well. As a side effect, a new line character is now accepted, but this should not be an issue. Signed-off-by: Michal Nazarewicz Signed-off-by: Felipe Balbi --- diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 4a6961c517f..449186c9fd6 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c @@ -1103,8 +1103,8 @@ static int ffs_fs_parse_opts(struct ffs_sb_fill_data *data, char *opts) return 0; for (;;) { - char *end, *eq, *comma; unsigned long value; + char *eq, *comma; /* Option limit */ comma = strchr(opts, ','); @@ -1120,8 +1120,7 @@ static int ffs_fs_parse_opts(struct ffs_sb_fill_data *data, char *opts) *eq = 0; /* Parse value */ - value = simple_strtoul(eq + 1, &end, 0); - if (unlikely(*end != ',' && *end != 0)) { + if (kstrtoul(eq + 1, 0, &value)) { pr_err("%s: invalid value: %s\n", opts, eq + 1); return -EINVAL; }