From: Xiubo Li <Li.Xiubo@freescale.com>
To: <sameo@linux.intel.com>, <lee.jones@linaro.org>
Cc: <linux-kernel@vger.kernel.org>, Xiubo Li <Li.Xiubo@freescale.com>
Subject: [PATCH] mfd: core: Fix possible ZERO_SIZE_PTR pointer dereferencing error.
Date: Thu, 18 Sep 2014 16:21:39 +0800 [thread overview]
Message-ID: <1411028499-44474-1-git-send-email-Li.Xiubo@freescale.com> (raw)
Since we cannot make sure the 'cell->num_resources' will always be none
zero here, and then if either equal to zero, the kzalloc() will return
ZERO_SIZE_PTR, which equals to ((void *)16).
So this patch fix this with just doing the zero check before calling
kzalloc().
Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
drivers/mfd/mfd-core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 892d343..54c7e35 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -89,6 +89,9 @@ static int mfd_add_device(struct device *parent, int id,
int ret = -ENOMEM;
int r;
+ if (!cell->num_resources)
+ return -EINVAL;
+
pdev = platform_device_alloc(cell->name, id + cell->id);
if (!pdev)
goto fail_alloc;
--
2.1.0.27.g96db324
next reply other threads:[~2014-09-18 8:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 8:21 Xiubo Li [this message]
2014-10-06 21:14 ` Lee Jones
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=1411028499-44474-1-git-send-email-Li.Xiubo@freescale.com \
--to=li.xiubo@freescale.com \
--cc=lee.jones@linaro.org \
--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
all inboxes | Powered by JetHome®