From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Vivek Goyal <vgoyal@redhat.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Vinod Koul <vinod.koul@intel.com>, Cliff Wickman <cpw@sgi.com>,
Jiang Liu <jiang.liu@linux.intel.com>,
Jakub Sitnicki <jsitnicki@gmail.com>,
Thierry Reding <treding@nvidia.com>, Mike Travis <travis@sgi.com>,
linux-kernel@vger.kernel.org
Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Subject: [PATCH] kernel/resource: Invalid memory access in __release_resource
Date: Mon, 20 Apr 2015 18:22:52 +0200 [thread overview]
Message-ID: <1429546972-28400-1-git-send-email-ricardo.ribalda@gmail.com> (raw)
When a resource is initialized via of_platform_populate.
resource->parent is initialized to NULL via kzalloc.
(of_platform_populate->of_device_alloc->of_address_to_resource)
If of_platform_depopulate is called later, resource->parent is
accessed (Offset 0x30 of address 0), causing a kernel error.
This patch evaluates resouce->parent before accessing it. If it
is not initialized, -EACCESS is returned.
Fixes:
BUG: unable to handle kernel NULL pointer deference at 0000000000000030
IP: release_resource+0x26/0x90
Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
kernel/resource.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/resource.c b/kernel/resource.c
index 90552aa..35dc716 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -237,6 +237,9 @@ static int __release_resource(struct resource *old)
{
struct resource *tmp, **p;
+ if (!old->parent)
+ return -EINVAL;
+
p = &old->parent->child;
for (;;) {
tmp = *p;
--
2.1.4
next reply other threads:[~2015-04-20 16:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-20 16:22 Ricardo Ribalda Delgado [this message]
2015-04-20 19:28 ` Bjorn Helgaas
2015-04-20 20:24 ` Ricardo Ribalda Delgado
2015-04-20 20:36 ` Bjorn Helgaas
2015-04-20 20:49 ` Ricardo Ribalda Delgado
2015-04-21 6:59 ` Thierry Reding
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=1429546972-28400-1-git-send-email-ricardo.ribalda@gmail.com \
--to=ricardo.ribalda@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=bhelgaas@google.com \
--cc=cpw@sgi.com \
--cc=jiang.liu@linux.intel.com \
--cc=jsitnicki@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=travis@sgi.com \
--cc=treding@nvidia.com \
--cc=vgoyal@redhat.com \
--cc=vinod.koul@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
all inboxes | Powered by JetHome®