Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1265198

Re: [PATCH] mtd: phram: error handling

From Andy Shevchenko <andy.shevchenko@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] mtd: phram: error handling
Date 2015-11-08 22:30 +0100
Message-ID <qsFHc-5tw-7@gated-at.bofh.it> (permalink)
References <qstPH-6fg-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sun, Nov 8, 2015 at 10:47 AM, Saurabh Sengar <saurabh.truth@gmail.com> wrote:
> registering the device with NULL pointer can lead to crash,
> hence fixing it.

Hmm… Why not just checking it before an register attempt? I think user
is in right to know as many problems as they have at one shot, with
your patch if there are two problems the user has to try twice.

>
> Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com>
> ---
> in case of 'illegal start address' or 'illegal device length', name pointer is getting freed.
> we shouldn't register the device with NULL pointer.
>
>  drivers/mtd/devices/phram.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
> index 8b66e52..9a7aed3 100644
> --- a/drivers/mtd/devices/phram.c
> +++ b/drivers/mtd/devices/phram.c
> @@ -249,12 +249,14 @@ static int phram_setup(const char *val)
>         if (ret) {
>                 kfree(name);
>                 parse_err("illegal start address\n");
> +               goto err;
>         }
>
>         ret = parse_num64(&len, token[2]);
>         if (ret) {
>                 kfree(name);
>                 parse_err("illegal device length\n");
> +               goto err;
>         }
>
>         ret = register_device(name, start, len);
> @@ -262,7 +264,7 @@ static int phram_setup(const char *val)
>                 pr_info("%s device: %#llx at %#llx\n", name, len, start);
>         else
>                 kfree(name);
> -
> +err:
>         return ret;
>  }
>
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] mtd: phram: error handling Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-08 09:50 +0100
  Re: [PATCH] mtd: phram: error handling Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-11-08 22:30 +0100
    [PATCH v2] mtd: phram: error handling Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-09 07:30 +0100
      Re: [PATCH v2] mtd: phram: error handling Brian Norris <computersforpeace@gmail.com> - 2015-11-10 19:30 +0100
        [PATCH] mtd: phram: error handling Joe Perches <joe@perches.com> - 2015-11-10 19:40 +0100
          Re: [PATCH] mtd: phram: error handling Joe Perches <joe@perches.com> - 2015-11-10 19:50 +0100
            Re: [PATCH] mtd: phram: error handling Brian Norris <computersforpeace@gmail.com> - 2015-11-10 20:10 +0100
              [PATCH] mtd: phram: error handling Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-10 20:30 +0100
                Re: [PATCH] mtd: phram: error handling Brian Norris <computersforpeace@gmail.com> - 2015-11-10 20:50 +0100
                [PATCH] mtd: phram: error handling Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-11 09:30 +0100
                Re: [PATCH] mtd: phram: error handling Brian Norris <computersforpeace@gmail.com> - 2015-11-11 20:50 +0100
                [PATCH] mtd: phram: error handling Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-12 07:30 +0100
          Re: [PATCH] mtd: phram: error handling Brian Norris <computersforpeace@gmail.com> - 2015-11-10 19:50 +0100

csiph-web