linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/1] mmc: sdhci-spear: Fix NULL pointer dereference
@ 2013-09-12  9:04 Sachin Kamat
  2013-09-12  9:24 ` Viresh Kumar
  2013-10-21  3:10 ` Sachin Kamat
  0 siblings, 2 replies; 4+ messages in thread
From: Sachin Kamat @ 2013-09-12  9:04 UTC (permalink / raw)
  To: linux-mmc; +Cc: cjb, spear-devel, sachin.kamat, Viresh Kumar

pdata could be NULL if cd_gpio = -1. Dereference pdata only
if it is not NULL.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
---
Compile tested.
Changes since v1:
* Moved the pdata assignment inside if condition.
---
 drivers/mmc/host/sdhci-spear.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c
index 2dba9f8..76ddd89 100644
--- a/drivers/mmc/host/sdhci-spear.c
+++ b/drivers/mmc/host/sdhci-spear.c
@@ -84,14 +84,12 @@ static struct sdhci_plat_data *sdhci_probe_config_dt(struct platform_device *pde
 	/* If pdata is required */
 	if (cd_gpio != -1) {
 		pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
-		if (!pdata) {
+		if (!pdata)
 			dev_err(&pdev->dev, "DT: kzalloc failed\n");
-			return ERR_PTR(-ENOMEM);
-		}
+		else
+			pdata->card_int_gpio = cd_gpio;
 	}
 
-	pdata->card_int_gpio = cd_gpio;
-
 	return pdata;
 }
 #else
-- 
1.7.9.5


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

end of thread, other threads:[~2013-10-21  3:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-12  9:04 [PATCH v2 1/1] mmc: sdhci-spear: Fix NULL pointer dereference Sachin Kamat
2013-09-12  9:24 ` Viresh Kumar
2013-09-27  9:41   ` Sachin Kamat
2013-10-21  3:10 ` Sachin Kamat

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).