Re: [PATCH 1/1] mmc: sdhci-spear: Fix NULL pointer dereference

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12 September 2013 12:13, Sachin Kamat <sachin.kamat@xxxxxxxxxx> wrote:
> pdata could be NULL if cd_gpio = -1. Hence move the NULL check
> outside the if condition.
>
> Signed-off-by: Sachin Kamat <sachin.kamat@xxxxxxxxxx>
> Cc: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
> ---
> Only compile tested.
> ---
>  drivers/mmc/host/sdhci-spear.c |   10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c
> index 2dba9f8..4f3557a 100644
> --- a/drivers/mmc/host/sdhci-spear.c
> +++ b/drivers/mmc/host/sdhci-spear.c
> @@ -82,12 +82,12 @@ static struct sdhci_plat_data *sdhci_probe_config_dt(struct platform_device *pde
>                 cd_gpio = -1;
>
>         /* If pdata is required */
> -       if (cd_gpio != -1) {
> +       if (cd_gpio != -1)
>                 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> -               if (!pdata) {
> -                       dev_err(&pdev->dev, "DT: kzalloc failed\n");
> -                       return ERR_PTR(-ENOMEM);
> -               }
> +
> +       if (!pdata) {
> +               dev_err(&pdev->dev, "pdata is NULL\n");
> +               return ERR_PTR(-ENOMEM);
>         }
>
>         pdata->card_int_gpio = cd_gpio;

Or better move above line in the if block? We are already printing
error in probe..
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux