mmc: sdhci-spear: Fix NULL pointer dereference

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>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>
This commit is contained in:
Sachin Kamat 2014-02-25 15:18:21 +05:30 committed by Chris Ball
parent 43aaa50f17
commit eab36b2478
1 changed files with 3 additions and 5 deletions

View File

@ -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