mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] mtd: atmel_nand: fix null pointer dereference
@ 2014-09-02 19:02 Raphaël Poggi
  2014-09-02 19:04 ` Raphaël Poggi
  0 siblings, 1 reply; 3+ messages in thread
From: Raphaël Poggi @ 2014-09-02 19:02 UTC (permalink / raw)
  To: barebox; +Cc: Raphaël Poggi

We need to allocate pdata for device tree and non device tree probe.
In device tree probe we use pdata to fill structure member with dts data.
In non device tree probe we use the pdata to handle platform_data.

Signed-off-by: Raphaël Poggi <poggi.raph@gmail.com>
---
 drivers/mtd/nand/atmel_nand.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index 910ecc3..1e7c6c6 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -1194,6 +1194,10 @@ static int __init atmel_nand_probe(struct device_d *dev)
 	if (!host)
 		return -ENOMEM;
 
+	pdata = kzalloc(sizeof(struct atmel_nand_data), GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
+
 	host->io_base = dev_request_mem_region(dev, 0);
 
 	mtd = &host->mtd;
@@ -1206,10 +1210,6 @@ static int __init atmel_nand_probe(struct device_d *dev)
 		if (res)
 			goto err_no_card;
 	} else {
-		pdata = kzalloc(sizeof(struct atmel_nand_data), GFP_KERNEL);
-		if (!pdata)
-			return -ENOMEM;
-
 		memcpy(host->board, dev->platform_data, sizeof(struct atmel_nand_data));
 	}
 
-- 
1.8.3.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2014-09-03  6:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-02 19:02 [PATCH] mtd: atmel_nand: fix null pointer dereference Raphaël Poggi
2014-09-02 19:04 ` Raphaël Poggi
2014-09-03  6:58   ` Sascha Hauer

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