linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: linux-kernel@vger.kernel.org
Cc: Waldemar Brodkorb <mail@waldemar-brodkorb.de>,
	Jesper Nilsson <jespern@axis.com>,
	Mikael Starvik <starvik@axis.com>,
	linux-cris-kernel@axis.com, Guenter Roeck <linux@roeck-us.net>
Subject: [RFC PATCH 7/8] resource: Add NULL check in next_resource
Date: Sun, 21 Sep 2014 09:27:17 -0700	[thread overview]
Message-ID: <1411316838-15135-8-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1411316838-15135-1-git-send-email-linux@roeck-us.net>

Commit 8c86e70acead ("resource: provide new functions to walk through
resources") adds a suble new requirement that iomem_resource.child must
not be NULL when walk_system_ram_range is called. This can cause a crash
if it turns out that there are no children. The crash ('Unable to handle
kernel NULL pointer dereference') is seen when trying to test a crisv32
image on kernels with this commit applied.

Fix by adding a NULL check into next_resource().

Fixes: 8c86e70acead ("resource: provide new functions to walk through resources")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 kernel/resource.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/resource.c b/kernel/resource.c
index 60c5a38..00c57ad 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -61,6 +61,9 @@ static DEFINE_SPINLOCK(bootmem_resource_lock);
 
 static struct resource *next_resource(struct resource *p, bool sibling_only)
 {
+	if (p == NULL)
+		return NULL;
+
 	/* Caller wants to traverse through siblings only */
 	if (sibling_only)
 		return p->sibling;
-- 
1.9.1


  parent reply	other threads:[~2014-09-21 16:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-21 16:27 [RFC PATCH 0/8] cris: Patches needed on top of v3.17-rc5 Guenter Roeck
2014-09-21 16:27 ` [RFC PATCH 1/8] cris: Add support for early console Guenter Roeck
2014-09-21 16:27 ` [RFC PATCH 2/8] cris: Add serial driver for Cris v32 Guenter Roeck
2014-09-21 16:27 ` [RFC PATCH 3/8] cris: Add dummy free_initrd_mem Guenter Roeck
2014-09-21 16:27 ` [RFC PATCH 4/8] cris: time.c: Add missing include file to fix compile error Guenter Roeck
2014-09-21 16:27 ` [RFC PATCH 5/8] cris: Add basic qemu_defconfig Guenter Roeck
2014-09-21 16:27 ` [RFC PATCH 6/8] tty: crisv32: Coding style cleanup, delete dead code Guenter Roeck
2014-09-21 16:27 ` Guenter Roeck [this message]
2014-09-21 16:27 ` [RFC PATCH 8/8] Revert "percpu: free percpu allocation info for uniprocessor system" Guenter Roeck
2014-09-21 17:23   ` Mikael Starvik
2014-09-21 18:37     ` Guenter Roeck
2014-09-21 19:19       ` Waldemar Brodkorb
2014-09-21 20:08         ` Guenter Roeck
2014-09-21 21:12   ` Tejun Heo

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=1411316838-15135-8-git-send-email-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=jespern@axis.com \
    --cc=linux-cris-kernel@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mail@waldemar-brodkorb.de \
    --cc=starvik@axis.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;
as well as URLs for NNTP newsgroup(s).