From: Brian Harring <ferringb@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: sameo@linux.intel.com, richard.rojfors@pelagicore.com
Subject: [PATCH] add platform_data only if non NULL
Date: Sun, 3 Oct 2010 18:50:56 -0700 [thread overview]
Message-ID: <20101004015056.GA22095@hrair> (raw)
[-- Attachment #1: Type: text/plain, Size: 1230 bytes --]
If a NULL or 0 size platform_data is added, the underlying dup results in a pointer into nullspace- meaning drivers can't do null checks for platform_data.
This fixes an oops during probing for drivers/net/ks8842, and drivers/mmc/host/sdhci-pltform when the mfd is timberdale
Signed-off-by: Brian Harring <ferringb@gmail.com>
---
drivers/mfd/mfd-core.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index 1823a57..eee73a8 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -38,10 +38,15 @@ static int mfd_add_device(struct device *parent, int id,
pdev->dev.parent = parent;
platform_set_drvdata(pdev, cell->driver_data);
- ret = platform_device_add_data(pdev,
- cell->platform_data, cell->data_size);
- if (ret)
- goto fail_res;
+ if (cell->data_size) {
+ ret = platform_device_add_data(pdev,
+ cell->platform_data, cell->data_size);
+ if (ret)
+ goto fail_res;
+ } else {
+ /* potentially nulled already, just being paranoid. */
+ pdev->dev.platform_data = NULL;
+ }
for (r = 0; r < cell->num_resources; r++) {
res[r].name = cell->resources[r].name;
--
1.7.2
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
next reply other threads:[~2010-10-04 1:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-04 1:50 Brian Harring [this message]
2010-10-18 23:25 ` [PATCH] add platform_data only if non NULL Samuel Ortiz
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=20101004015056.GA22095@hrair \
--to=ferringb@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=richard.rojfors@pelagicore.com \
--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