[PATCH v3] UBIFS: replace simple_strtoul() with kstrtoint()

Geert Uytterhoeven geert at linux-m68k.org
Tue May 20 23:30:05 PDT 2014


On Wed, May 21, 2014 at 5:00 AM, Zhang Zhen <zhenzhang.zhang at huawei.com> wrote:
> @@ -1922,7 +1922,10 @@ static struct ubi_volume_desc *open_ubi(const char *name, int mode)
>         if (!isdigit(name[3]))
>                 return ERR_PTR(-EINVAL);
>
> -       dev = simple_strtoul(name + 3, &endptr, 0);
> +       endptr = name + 3;

As Adrian pointed out, endptr is used later, and it must point to the
character after the parsed number.

> +       ret = kstrtoint(endptr, 0, &dev);
> +       if (ret)
> +               return ERR_PTR(-EINVAL);
>
>         /* ubiY method */
>         if (*endptr == '\0')
> @@ -1930,7 +1933,10 @@ static struct ubi_volume_desc *open_ubi(const char *name, int mode)
>
>         /* ubiX_Y method */
>         if (*endptr == '_' && isdigit(endptr[1])) {
> -               vol = simple_strtoul(endptr + 1, &endptr, 0);
> +               endptr = endptr + 1;
> +               ret = kstrtoint(endptr, 0, &vol);
> +               if (ret)
> +                       return ERR_PTR(-EINVAL);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds



More information about the linux-mtd mailing list