All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bas.Vermeulen@novero.com (Bas Vermeulen)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] imx serial driver: NULL pointer dereference in serial_imx_probe/remove
Date: Thu, 11 Feb 2010 19:02:02 +0100	[thread overview]
Message-ID: <4B74461A.1050403@novero.com> (raw)

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>

             reply	other threads:[~2010-02-11 18:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-11 18:02 Bas Vermeulen [this message]
2010-02-11 18:58 ` [PATCH] imx serial driver: NULL pointer dereference in serial_imx_probe/remove Baruch Siach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B74461A.1050403@novero.com \
    --to=bas.vermeulen@novero.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.