mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Saurabh Sengar <saurabh.truth@gmail.com>
To: andy.shevchenko@gmail.com
Cc: joern@lazybastard.org, dwmw2@infradead.org,
	computersforpeace@gmail.com, linux-mtd@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Saurabh Sengar <saurabh.truth@gmail.com>
Subject: [PATCH v2] mtd: phram: error handling
Date: Mon,  9 Nov 2015 11:53:18 +0530	[thread overview]
Message-ID: <1447050198-20562-1-git-send-email-saurabh.truth@gmail.com> (raw)
In-Reply-To: <CAHp75VeUie1VdWUgXfFD6XqU5t_9j-40papME3-8MUvjMh1iMw@mail.gmail.com>

registering the device with NULL pointer can lead to crash,
hence fixing it

Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com>
---
> Andy Shevchenko wrote:
> 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.
Yes, taken your feedback, fixing it here in v2 as you recommended

 drivers/mtd/devices/phram.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c
index 8b66e52..46b7a8a 100644
--- a/drivers/mtd/devices/phram.c
+++ b/drivers/mtd/devices/phram.c
@@ -257,6 +257,9 @@ static int phram_setup(const char *val)
 		parse_err("illegal device length\n");
 	}
 
+	if(!name)
+		return -EINVAL;
+
 	ret = register_device(name, start, len);
 	if (!ret)
 		pr_info("%s device: %#llx at %#llx\n", name, len, start);
-- 
1.9.1


  reply	other threads:[~2015-11-09  6:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-08  8:47 [PATCH] " Saurabh Sengar
2015-11-08 21:23 ` Andy Shevchenko
2015-11-09  6:23   ` Saurabh Sengar [this message]
2015-11-10 18:20     ` [PATCH v2] " Brian Norris
2015-11-10 18:33       ` [PATCH] " Joe Perches
2015-11-10 18:39         ` Brian Norris
2015-11-10 18:45           ` Joe Perches
2015-11-10 19:03             ` Brian Norris
2015-11-10 19:27               ` Saurabh Sengar
2015-11-10 19:41                 ` Brian Norris
2015-11-11  8:23                   ` Saurabh Sengar
2015-11-11 19:44                     ` Brian Norris
2015-11-12  6:23                       ` Saurabh Sengar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1447050198-20562-1-git-send-email-saurabh.truth@gmail.com \
    --to=saurabh.truth@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=joern@lazybastard.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®