Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit afd2e186 authored by Michal Nazarewicz's avatar Michal Nazarewicz Committed by Felipe Balbi
Browse files

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: default avatarMichal Nazarewicz <mina86@mina86.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent cd76213e
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -1103,8 +1103,8 @@ static int ffs_fs_parse_opts(struct ffs_sb_fill_data *data, char *opts)
		return 0;
		return 0;


	for (;;) {
	for (;;) {
		char *end, *eq, *comma;
		unsigned long value;
		unsigned long value;
		char *eq, *comma;


		/* Option limit */
		/* Option limit */
		comma = strchr(opts, ',');
		comma = strchr(opts, ',');
@@ -1120,8 +1120,7 @@ static int ffs_fs_parse_opts(struct ffs_sb_fill_data *data, char *opts)
		*eq = 0;
		*eq = 0;


		/* Parse value */
		/* Parse value */
		value = simple_strtoul(eq + 1, &end, 0);
		if (kstrtoul(eq + 1, 0, &value)) {
		if (unlikely(*end != ',' && *end != 0)) {
			pr_err("%s: invalid value: %s\n", opts, eq + 1);
			pr_err("%s: invalid value: %s\n", opts, eq + 1);
			return -EINVAL;
			return -EINVAL;
		}
		}