mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander Beregalov <a.beregalov@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Alexander Beregalov <a.beregalov@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: [PATCH 1/4] mtd: mxc_nand: avoid NULL pointer dereference
Date: Thu,  7 Jan 2010 04:48:38 +0300	[thread overview]
Message-ID: <1262828921-29517-1-git-send-email-a.beregalov@gmail.com> (raw)

Assign nand_chip and host only if host is not NULL.

Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Alexander Beregalov <a.beregalov@gmail.com>
---
 drivers/mtd/nand/mxc_nand.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 45dec57..4ace54c 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -881,12 +881,14 @@ static int __devexit mxcnd_remove(struct platform_device *pdev)
 static int mxcnd_suspend(struct platform_device *pdev, pm_message_t state)
 {
 	struct mtd_info *mtd = platform_get_drvdata(pdev);
-	struct nand_chip *nand_chip = mtd->priv;
-	struct mxc_nand_host *host = nand_chip->priv;
+	struct nand_chip *nand_chip;
+	struct mxc_nand_host *host;
 	int ret = 0;
 
 	DEBUG(MTD_DEBUG_LEVEL0, "MXC_ND : NAND suspend\n");
 	if (mtd) {
+		nand_chip = mtd->priv;
+		host = nand_chip->priv;
 		ret = mtd->suspend(mtd);
 		/* Disable the NFC clock */
 		clk_disable(host->clk);
@@ -898,13 +900,15 @@ static int mxcnd_suspend(struct platform_device *pdev, pm_message_t state)
 static int mxcnd_resume(struct platform_device *pdev)
 {
 	struct mtd_info *mtd = platform_get_drvdata(pdev);
-	struct nand_chip *nand_chip = mtd->priv;
-	struct mxc_nand_host *host = nand_chip->priv;
+	struct nand_chip *nand_chip;
+	struct mxc_nand_host *host;
 	int ret = 0;
 
 	DEBUG(MTD_DEBUG_LEVEL0, "MXC_ND : NAND resume\n");
 
 	if (mtd) {
+		nand_chip = mtd->priv;
+		host = nand_chip->priv;
 		/* Enable the NFC clock */
 		clk_enable(host->clk);
 		mtd->resume(mtd);
-- 
1.6.6


             reply	other threads:[~2010-01-07  1:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-07  1:48 Alexander Beregalov [this message]
2010-01-07  1:48 ` [PATCH 2/4] SCSI: pm8001: " Alexander Beregalov
2010-01-07  1:48   ` [PATCH 3/4] ISDN: hysdn: " Alexander Beregalov
2010-01-07  1:48     ` [PATCH 4/4] uml: line.c: " Alexander Beregalov
2010-01-07  4:32       ` Jeff Dike
2010-01-07 15:56         ` Alexander Beregalov

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=1262828921-29517-1-git-send-email-a.beregalov@gmail.com \
    --to=a.beregalov@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®