public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] add platform_data only if non NULL
@ 2010-10-04  1:50 Brian Harring
  2010-10-18 23:25 ` Samuel Ortiz
  0 siblings, 1 reply; 2+ messages in thread
From: Brian Harring @ 2010-10-04  1:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: sameo, richard.rojfors

[-- 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 --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-10-18 23:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-04  1:50 [PATCH] add platform_data only if non NULL Brian Harring
2010-10-18 23:25 ` Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox