lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1262828921-29517-1-git-send-email-a.beregalov@gmail.com>
Date:	Thu,  7 Jan 2010 04:48:38 +0300
From:	Alexander Beregalov <a.beregalov@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	Alexander Beregalov <a.beregalov@...il.com>,
	David Woodhouse <dwmw2@...radead.org>
Subject: [PATCH 1/4] mtd: mxc_nand: avoid NULL pointer dereference

Assign nand_chip and host only if host is not NULL.

Cc: David Woodhouse <dwmw2@...radead.org>
Signed-off-by: Alexander Beregalov <a.beregalov@...il.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ