]> git.karo-electronics.de Git - linux-beck.git/commitdiff
mmc: sdhci-spear: Fix NULL pointer dereference
authorSachin Kamat <sachin.kamat@linaro.org>
Tue, 25 Feb 2014 09:48:21 +0000 (15:18 +0530)
committerChris Ball <chris@printf.net>
Tue, 25 Feb 2014 20:42:52 +0000 (15:42 -0500)
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>
drivers/mmc/host/sdhci-spear.c

index 2dba9f8d1760313e3c47eeca756d6a59247ed924..76ddd89a688ee715544e6a09598a59747c5fd561 100644 (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