Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eab36b24 authored by Sachin Kamat's avatar Sachin Kamat Committed by Chris Ball
Browse files

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: default avatarSachin Kamat <sachin.kamat@linaro.org>
Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarChris Ball <chris@printf.net>
parent 43aaa50f
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -84,13 +84,11 @@ 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;
	}

	return pdata;
}