瀏覽代碼

serial: imx: fix NULL dereference Oops when pdata == NULL

The platform code doesn't have to provide platform data to get sensible
default behaviour from the imx serial driver.

This patch does not handle NULL dereference in the IrDA case, which still
requires a valid platform data pointer (in imx_startup()/imx_shutdown()),
since I don't know whether there is a sensible default behaviour, or
should the operation just fail cleanly.

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Cc: Baruch Siach <baruch@tkos.co.il>
Cc: Alan Cox <alan@linux.intel.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Oskar Schirmer <os@emlix.com>
Cc: Fabian Godehardt <fg@emlix.com>
Cc: Daniel Glöckner <dg@emlix.com>
Cc: stable <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Baruch Siach 15 年之前
父節點
當前提交
bbcd18d1b3
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      drivers/serial/imx.c

+ 3 - 3
drivers/serial/imx.c

@@ -1279,7 +1279,7 @@ static int serial_imx_probe(struct platform_device *pdev)
 		sport->use_irda = 1;
 		sport->use_irda = 1;
 #endif
 #endif
 
 
-	if (pdata->init) {
+	if (pdata && pdata->init) {
 		ret = pdata->init(pdev);
 		ret = pdata->init(pdev);
 		if (ret)
 		if (ret)
 			goto clkput;
 			goto clkput;
@@ -1292,7 +1292,7 @@ static int serial_imx_probe(struct platform_device *pdev)
 
 
 	return 0;
 	return 0;
 deinit:
 deinit:
-	if (pdata->exit)
+	if (pdata && pdata->exit)
 		pdata->exit(pdev);
 		pdata->exit(pdev);
 clkput:
 clkput:
 	clk_put(sport->clk);
 	clk_put(sport->clk);
@@ -1321,7 +1321,7 @@ static int serial_imx_remove(struct platform_device *pdev)
 
 
 	clk_disable(sport->clk);
 	clk_disable(sport->clk);
 
 
-	if (pdata->exit)
+	if (pdata && pdata->exit)
 		pdata->exit(pdev);
 		pdata->exit(pdev);
 
 
 	iounmap(sport->port.membase);
 	iounmap(sport->port.membase);