mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] mtd: ubi: avoid NULL pointer dereference in ubi_get_device
Date: Wed, 19 Mar 2014 14:25:02 +0100	[thread overview]
Message-ID: <1395235502-27629-1-git-send-email-p.zabel@pengutronix.de> (raw)

If the ubidetach command is given a number that passes the range check
in ubi_detach_mtd_dev, but at which index the ubi_devices array contains
a NULL pointer, ubi_get_device tries to dereference this NULL pointer
to increment the ubi device reference count.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/mtd/ubi/build.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index da21f69..b908fcd 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -104,6 +104,8 @@ struct ubi_device *ubi_get_device(int ubi_num)
 	struct ubi_device *ubi;
 
 	ubi = ubi_devices[ubi_num];
+	if (!ubi)
+		return NULL;
 
 	ubi->ref_count++;
 
-- 
1.9.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2014-03-19 13:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-19 13:25 Philipp Zabel [this message]
2014-03-23  8:47 ` Sascha Hauer

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=1395235502-27629-1-git-send-email-p.zabel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=barebox@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