Skip to contentSkip to conversation

IMX serial: Check platform data pointer before use

PATCH New Yauhen Kharuzhy 3 participants 3 messages Jan 16, 2010 – Jan 17, 2010 Arm i.MX and Layerscape

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IMX serial: Check platform data pointer before use

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

---
 drivers/serial/imx.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/serial/imx.c +3 -3
index 18130f1..8c0dd13 100644
@@ -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);
Signature · 1 line
1.6.5.7
#1 lore raw

PATCH 1/1 IMX serial: Check platform data pointer before use

Quoted 4 lines · Yauhen Kharuzhy

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

Signature · 9 lines
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>
#2 lore raw

PATCH 1/1 IMX serial: Check platform data pointer before use

In reply to Yauhen Kharuzhy

Hi Yauhen,

Quoted 4 lines · Yauhen Kharuzhy

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

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

Quoted 37 lines
---
 drivers/serial/imx.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/serial/imx.c +3 -3
index 18130f1..8c0dd13 100644
@@ -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);
Signature · 1 line
1.6.5.7
Signature · 3 lines
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -