mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Fainelli <florian@openwrt.org>
To: Samuel Ortiz <sameo@linux.intel.com>,
	"linux-kernel" <linux-kernel@vger.kernel.org>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>
Subject: [PATCH] MFD: prevent null pointer dereference in mfd_add_device
Date: Sat, 15 May 2010 21:57:10 +0200	[thread overview]
Message-ID: <201005152157.13121.florian@openwrt.org> (raw)

If a driver calls mfd_add_device with a NULL argument for the mem_base resource
we will end up dereferencing it without checking for its validity here:
res[r].start = mem_base->start cell->resources[r].start; (line 53 of mfd-core.c)

This patch adds the checking on the mem_base argument and bails out accordingly
if it is NULL.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
CC: stable@kernel.org
---
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 8ffbb7a..f890b27 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -49,6 +49,8 @@ static int mfd_add_device(struct device *parent, int id,
 
 		/* Find out base to use */
 		if (cell->resources[r].flags & IORESOURCE_MEM) {
+			if (!mem_base)
+				goto fail_res;
 			res[r].parent = mem_base;
 			res[r].start = mem_base->start +
 				cell->resources[r].start;

             reply	other threads:[~2010-05-15 19:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-15 19:57 Florian Fainelli [this message]
2010-05-15 20:01 ` Florian Fainelli

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=201005152157.13121.florian@openwrt.org \
    --to=florian@openwrt.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sameo@linux.intel.com \
    /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

Powered by JetHome