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

* Re: [PATCH] mtd: atmel_nand: fix null pointer dereference
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Raphaël Poggi @ 2014-09-02 19:04 UTC (permalink / raw)
  To: barebox

I think this patch could be squash in [PATCH v3 3/3] mtd: atmel_nand:
add support for device tree

2014-09-02 21:02 GMT+02:00 Raphaël Poggi <poggi.raph@gmail.com>:
> 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

* Re: [PATCH] mtd: atmel_nand: fix null pointer dereference
  2014-09-02 19:04 ` Raphaël Poggi
@ 2014-09-03  6:58   ` Sascha Hauer
  0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2014-09-03  6:58 UTC (permalink / raw)
  To: Raphaël Poggi; +Cc: barebox

On Tue, Sep 02, 2014 at 09:04:48PM +0200, Raphaël Poggi wrote:
> I think this patch could be squash in [PATCH v3 3/3] mtd: atmel_nand:
> add support for device tree

Did that, thanks.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
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