From: Sachin Kamat Date: Tue, 25 Feb 2014 09:48:21 +0000 (+0530) Subject: mmc: sdhci-spear: Fix NULL pointer dereference X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=eab36b2478aaed00ef381f4e855d4e0c14778a32;p=openwrt%2Fstaging%2Fblogic.git 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 Acked-by: Viresh Kumar Signed-off-by: Chris Ball --- diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c index 2dba9f8d1760..76ddd89a688e 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