Skip to content

Commit

Permalink
usb: gadget: FunctionFS: Use kstrtoul()
Browse files Browse the repository at this point in the history
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 <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Michal Nazarewicz authored and Felipe Balbi committed Jan 10, 2013
1 parent cd76213 commit afd2e18
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/usb/gadget/f_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, ',');
Expand All @@ -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;
}
Expand Down

0 comments on commit afd2e18

Please sign in to comment.