linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] imx serial driver: NULL pointer dereference in serial_imx_probe/remove
@ 2010-02-11 18:02 Bas Vermeulen
  2010-02-11 18:58 ` Baruch Siach
  0 siblings, 1 reply; 2+ messages in thread
From: Bas Vermeulen @ 2010-02-11 18:02 UTC (permalink / raw)
  To: linux-arm-kernel

Check for NULL pointer before dereferencing, as it is possible and legal 
to pass in NULL for the platform data for a serial port.

Signed-off-by: Bas Vermeulen <bas.vermeulen@novero.com>

diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index 60d665a..d00fcf8 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);

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: drivers-imx-serial-null-dereference.patch
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100211/5064c9a5/attachment.el>

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

* [PATCH] imx serial driver: NULL pointer dereference in serial_imx_probe/remove
  2010-02-11 18:02 [PATCH] imx serial driver: NULL pointer dereference in serial_imx_probe/remove Bas Vermeulen
@ 2010-02-11 18:58 ` Baruch Siach
  0 siblings, 0 replies; 2+ messages in thread
From: Baruch Siach @ 2010-02-11 18:58 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Bas,

On Thu, Feb 11, 2010 at 07:02:02PM +0100, Bas Vermeulen wrote:
> Check for NULL pointer before dereferencing, as it is possible and
> legal to pass in NULL for the platform data for a serial port.

Third time's the charm :-). This patch is already queued for .34 in Greg's tty 
quilt tree.

http://lists.infradead.org/pipermail/linux-arm-kernel/2010-January/007909.html
http://kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/gregkh-06-tty/serial-imx-fix-null-dereference-oops-when-pdata-null.patch
http://git.kernel.org/?p=linux/kernel/git/sfr/linux-next.git;a=commitdiff;h=ed8101ca0251cc0d05bedf577109bfb05b66f5dc

baruch

> Signed-off-by: Bas Vermeulen <bas.vermeulen@novero.com>
> 
> diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
> index 60d665a..d00fcf8 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);

-- 
                                                     ~. .~   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] 2+ messages in thread

end of thread, other threads:[~2010-02-11 18:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-11 18:02 [PATCH] imx serial driver: NULL pointer dereference in serial_imx_probe/remove Bas Vermeulen
2010-02-11 18:58 ` 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).