linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] IMX serial: Check platform data pointer before use
@ 2010-01-16 21:28 Yauhen Kharuzhy
  2010-01-16 21:44 ` Wolfram Sang
  2010-01-17  3:40 ` Baruch Siach
  0 siblings, 2 replies; 3+ messages in thread
From: Yauhen Kharuzhy @ 2010-01-16 21:28 UTC (permalink / raw)
  To: linux-arm-kernel

pdev->dev.platform_data can be NULL in driver probe function. This is
should be checked before any use of imxuart_platform_data structure.

Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
---
 drivers/serial/imx.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index 18130f1..8c0dd13 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -1279,7 +1279,7 @@ static int serial_imx_probe(struct platform_device *pdev)
 		sport->use_irda = 1;
 #endif
 
-	if (pdata->init) {
+	if (pdata && pdata->init) {
 		ret = pdata->init(pdev);
 		if (ret)
 			goto clkput;
@@ -1292,7 +1292,7 @@ static int serial_imx_probe(struct platform_device *pdev)
 
 	return 0;
 deinit:
-	if (pdata->exit)
+	if (pdata && pdata->exit)
 		pdata->exit(pdev);
 clkput:
 	clk_put(sport->clk);
@@ -1321,7 +1321,7 @@ static int serial_imx_remove(struct platform_device *pdev)
 
 	clk_disable(sport->clk);
 
-	if (pdata->exit)
+	if (pdata && pdata->exit)
 		pdata->exit(pdev);
 
 	iounmap(sport->port.membase);
-- 
1.6.5.7

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

* [PATCH] IMX serial: Check platform data pointer before use
  2010-01-16 21:28 [PATCH] IMX serial: Check platform data pointer before use Yauhen Kharuzhy
@ 2010-01-16 21:44 ` Wolfram Sang
  2010-01-17  3:40 ` Baruch Siach
  1 sibling, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2010-01-16 21:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Jan 16, 2010 at 11:28:30PM +0200, Yauhen Kharuzhy wrote:
> pdev->dev.platform_data can be NULL in driver probe function. This is
> should be checked before any use of imxuart_platform_data structure.
> 
> Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>

Acked-by: Wolfram Sang <w.sang@pengutronix.de>

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100116/7ad51732/attachment.sig>

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

* [PATCH] IMX serial: Check platform data pointer before use
  2010-01-16 21:28 [PATCH] IMX serial: Check platform data pointer before use Yauhen Kharuzhy
  2010-01-16 21:44 ` Wolfram Sang
@ 2010-01-17  3:40 ` Baruch Siach
  1 sibling, 0 replies; 3+ messages in thread
From: Baruch Siach @ 2010-01-17  3:40 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Yauhen,

On Sat, Jan 16, 2010 at 11:28:30PM +0200, Yauhen Kharuzhy wrote:
> pdev->dev.platform_data can be NULL in driver probe function. This is
> should be checked before any use of imxuart_platform_data structure.
> 
> Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>

A similar patch is already in Greg's tty tree.

http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/tty/serial-imx-fix-null-dereference-oops-when-pdata-null.patch

> ---
>  drivers/serial/imx.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
> index 18130f1..8c0dd13 100644
> --- a/drivers/serial/imx.c
> +++ b/drivers/serial/imx.c
> @@ -1279,7 +1279,7 @@ static int serial_imx_probe(struct platform_device *pdev)
>  		sport->use_irda = 1;
>  #endif
>  
> -	if (pdata->init) {
> +	if (pdata && pdata->init) {
>  		ret = pdata->init(pdev);
>  		if (ret)
>  			goto clkput;
> @@ -1292,7 +1292,7 @@ static int serial_imx_probe(struct platform_device *pdev)
>  
>  	return 0;
>  deinit:
> -	if (pdata->exit)
> +	if (pdata && pdata->exit)
>  		pdata->exit(pdev);
>  clkput:
>  	clk_put(sport->clk);
> @@ -1321,7 +1321,7 @@ static int serial_imx_remove(struct platform_device *pdev)
>  
>  	clk_disable(sport->clk);
>  
> -	if (pdata->exit)
> +	if (pdata && pdata->exit)
>  		pdata->exit(pdev);
>  
>  	iounmap(sport->port.membase);
> -- 
> 1.6.5.7

-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

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

end of thread, other threads:[~2010-01-17  3:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-16 21:28 [PATCH] IMX serial: Check platform data pointer before use Yauhen Kharuzhy
2010-01-16 21:44 ` Wolfram Sang
2010-01-17  3:40 ` Baruch Siach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).