linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/1] mmc: sdhci-spear: Fix NULL pointer dereference
@ 2013-09-12  9:04 Sachin Kamat
  2013-09-12  9:24 ` Viresh Kumar
  2013-10-21  3:10 ` Sachin Kamat
  0 siblings, 2 replies; 4+ messages in thread
From: Sachin Kamat @ 2013-09-12  9:04 UTC (permalink / raw)
  To: linux-mmc; +Cc: cjb, spear-devel, sachin.kamat, Viresh Kumar

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>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
---
Compile tested.
Changes since v1:
* Moved the pdata assignment inside if condition.
---
 drivers/mmc/host/sdhci-spear.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c
index 2dba9f8..76ddd89 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
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] mmc: sdhci-spear: Fix NULL pointer dereference
  2013-09-12  9:04 [PATCH v2 1/1] mmc: sdhci-spear: Fix NULL pointer dereference Sachin Kamat
@ 2013-09-12  9:24 ` Viresh Kumar
  2013-09-27  9:41   ` Sachin Kamat
  2013-10-21  3:10 ` Sachin Kamat
  1 sibling, 1 reply; 4+ messages in thread
From: Viresh Kumar @ 2013-09-12  9:24 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: linux-mmc, Chris Ball, spear-devel

On 12 September 2013 14:34, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> 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>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> Compile tested.
> Changes since v1:
> * Moved the pdata assignment inside if condition.
> ---
>  drivers/mmc/host/sdhci-spear.c |    8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c
> index 2dba9f8..76ddd89 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

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] mmc: sdhci-spear: Fix NULL pointer dereference
  2013-09-12  9:24 ` Viresh Kumar
@ 2013-09-27  9:41   ` Sachin Kamat
  0 siblings, 0 replies; 4+ messages in thread
From: Sachin Kamat @ 2013-09-27  9:41 UTC (permalink / raw)
  To: Chris Ball; +Cc: linux-mmc

On 12 September 2013 14:54, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> On 12 September 2013 14:34, Sachin Kamat <sachin.kamat@linaro.org> wrote:
>> 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>
>> Cc: Viresh Kumar <viresh.kumar@linaro.org>
>> ---
>> Compile tested.
>> Changes since v1:
>> * Moved the pdata assignment inside if condition.
>> ---
>>  drivers/mmc/host/sdhci-spear.c |    8 +++-----
>>  1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c
>> index 2dba9f8..76ddd89 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
>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>


Ping Chris.

-- 
With warm regards,
Sachin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] mmc: sdhci-spear: Fix NULL pointer dereference
  2013-09-12  9:04 [PATCH v2 1/1] mmc: sdhci-spear: Fix NULL pointer dereference Sachin Kamat
  2013-09-12  9:24 ` Viresh Kumar
@ 2013-10-21  3:10 ` Sachin Kamat
  1 sibling, 0 replies; 4+ messages in thread
From: Sachin Kamat @ 2013-10-21  3:10 UTC (permalink / raw)
  To: linux-mmc; +Cc: Chris Ball, Sachin Kamat

On 12 September 2013 14:34, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> 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>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> Compile tested.
> Changes since v1:
> * Moved the pdata assignment inside if condition.
> ---
>  drivers/mmc/host/sdhci-spear.c |    8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c
> index 2dba9f8..76ddd89 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
> --
> 1.7.9.5
>

Gentle ping, Chris.


-- 
With warm regards,
Sachin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-21  3:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-12  9:04 [PATCH v2 1/1] mmc: sdhci-spear: Fix NULL pointer dereference Sachin Kamat
2013-09-12  9:24 ` Viresh Kumar
2013-09-27  9:41   ` Sachin Kamat
2013-10-21  3:10 ` Sachin Kamat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).