All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] Input: soc_button_array: Remove kfree on data allocated with devm_zalloc
@ 2014-07-25 11:34 pramod.gurav.etc
  2014-07-25 16:22 ` Dmitry Torokhov
  0 siblings, 1 reply; 8+ messages in thread
From: pramod.gurav.etc @ 2014-07-25 11:34 UTC (permalink / raw)
  To: linux-input, linux-kernel
  Cc: Pramod Gurav, Dmitry Torokhov, Lejun Zhu, Sachin Kamat

From: Pramod Gurav <pramod.gurav@smartplayin.com>

This patch does below:
- Removes kfree done on data allocated with devm_zalloc in probe
  path of the driver.
- Adds a check on return value from devm_kzalloc which was missing

CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
CC: Lejun Zhu <lejun.zhu@linux.intel.com>
CC: Sachin Kamat <sachin.kamat@linaro.org>

Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
---
 drivers/input/misc/soc_button_array.c |   17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index 5a6334b..fc64ec6 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -83,6 +83,9 @@ soc_button_device_create(struct pnp_dev *pdev,
 				       sizeof(*gpio_keys_pdata) +
 					sizeof(*gpio_keys) * MAX_NBUTTONS,
 				       GFP_KERNEL);
+	if (!gpio_keys_pdata)
+		return ERR_PTR(-ENOMEM);
+
 	gpio_keys = (void *)(gpio_keys_pdata + 1);
 
 	for (info = button_info; info->name; info++) {
@@ -102,20 +105,16 @@ soc_button_device_create(struct pnp_dev *pdev,
 		n_buttons++;
 	}
 
-	if (n_buttons == 0) {
-		error = -ENODEV;
-		goto err_free_mem;
-	}
+	if (n_buttons == 0)
+		return ERR_PTR(-ENODEV);
 
 	gpio_keys_pdata->buttons = gpio_keys;
 	gpio_keys_pdata->nbuttons = n_buttons;
 	gpio_keys_pdata->rep = autorepeat;
 
 	pd = platform_device_alloc("gpio-keys", PLATFORM_DEVID_AUTO);
-	if (!pd) {
-		error = -ENOMEM;
-		goto err_free_mem;
-	}
+	if (!pd)
+		return ERR_PTR(-ENOMEM);
 
 	error = platform_device_add_data(pd, gpio_keys_pdata,
 					 sizeof(*gpio_keys_pdata));
@@ -130,8 +129,6 @@ soc_button_device_create(struct pnp_dev *pdev,
 
 err_free_pdev:
 	platform_device_put(pd);
-err_free_mem:
-	devm_kfree(&pdev->dev, gpio_keys_pdata);
 	return ERR_PTR(error);
 }
 
-- 
1.7.9.5


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

* Re: [PATCH v2] Input: soc_button_array: Remove kfree on data allocated with devm_zalloc
  2014-07-25 11:34 [PATCH v2] Input: soc_button_array: Remove kfree on data allocated with devm_zalloc pramod.gurav.etc
@ 2014-07-25 16:22 ` Dmitry Torokhov
  2014-07-28  6:50   ` pramod gurav
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2014-07-25 16:22 UTC (permalink / raw)
  To: pramod.gurav.etc
  Cc: linux-input, linux-kernel, Pramod Gurav, Lejun Zhu, Sachin Kamat

Hi Pramod,

On Fri, Jul 25, 2014 at 05:04:34PM +0530, pramod.gurav.etc@gmail.com wrote:
> From: Pramod Gurav <pramod.gurav@smartplayin.com>
> 
> This patch does below:
> - Removes kfree done on data allocated with devm_zalloc in probe
>   path of the driver.
> - Adds a check on return value from devm_kzalloc which was missing
> 
> CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> CC: Lejun Zhu <lejun.zhu@linux.intel.com>
> CC: Sachin Kamat <sachin.kamat@linaro.org>
> 
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
> ---
>  drivers/input/misc/soc_button_array.c |   17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
> index 5a6334b..fc64ec6 100644
> --- a/drivers/input/misc/soc_button_array.c
> +++ b/drivers/input/misc/soc_button_array.c
> @@ -83,6 +83,9 @@ soc_button_device_create(struct pnp_dev *pdev,
>  				       sizeof(*gpio_keys_pdata) +
>  					sizeof(*gpio_keys) * MAX_NBUTTONS,
>  				       GFP_KERNEL);
> +	if (!gpio_keys_pdata)
> +		return ERR_PTR(-ENOMEM);

OK, that makes sense.

> +
>  	gpio_keys = (void *)(gpio_keys_pdata + 1);
>  
>  	for (info = button_info; info->name; info++) {
> @@ -102,20 +105,16 @@ soc_button_device_create(struct pnp_dev *pdev,
>  		n_buttons++;
>  	}
>  
> -	if (n_buttons == 0) {
> -		error = -ENODEV;
> -		goto err_free_mem;
> -	}
> +	if (n_buttons == 0)
> +		return ERR_PTR(-ENODEV);

But that one and the rest don't, because failure in
soc_button_device_create() does not necessarily mean that binding for
the whole device will fail. In this case we do not want unused memory
hang around.

Thanks.

-- 
Dmitry

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

* Re: [PATCH v2] Input: soc_button_array: Remove kfree on data allocated with devm_zalloc
  2014-07-25 16:22 ` Dmitry Torokhov
@ 2014-07-28  6:50   ` pramod gurav
  2014-07-28  7:10     ` Dmitry Torokhov
  0 siblings, 1 reply; 8+ messages in thread
From: pramod gurav @ 2014-07-28  6:50 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, Pramod Gurav, Lejun Zhu, Sachin Kamat

Hi Dmitry,

Thanks for the review.

On Fri, Jul 25, 2014 at 9:52 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> Hi Pramod,
>
> On Fri, Jul 25, 2014 at 05:04:34PM +0530, pramod.gurav.etc@gmail.com wrote:
>> From: Pramod Gurav <pramod.gurav@smartplayin.com>
>>
>> This patch does below:
>> - Removes kfree done on data allocated with devm_zalloc in probe
>>   path of the driver.
>> - Adds a check on return value from devm_kzalloc which was missing
>>
>> CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> CC: Lejun Zhu <lejun.zhu@linux.intel.com>
>> CC: Sachin Kamat <sachin.kamat@linaro.org>
>>
>> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
>> ---
>>  drivers/input/misc/soc_button_array.c |   17 +++++++----------
>>  1 file changed, 7 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
>> index 5a6334b..fc64ec6 100644
>> --- a/drivers/input/misc/soc_button_array.c
>> +++ b/drivers/input/misc/soc_button_array.c
>> @@ -83,6 +83,9 @@ soc_button_device_create(struct pnp_dev *pdev,
>>                                      sizeof(*gpio_keys_pdata) +
>>                                       sizeof(*gpio_keys) * MAX_NBUTTONS,
>>                                      GFP_KERNEL);
>> +     if (!gpio_keys_pdata)
>> +             return ERR_PTR(-ENOMEM);
>
> OK, that makes sense.
>
>> +
>>       gpio_keys = (void *)(gpio_keys_pdata + 1);
>>
>>       for (info = button_info; info->name; info++) {
>> @@ -102,20 +105,16 @@ soc_button_device_create(struct pnp_dev *pdev,
>>               n_buttons++;
>>       }
>>
>> -     if (n_buttons == 0) {
>> -             error = -ENODEV;
>> -             goto err_free_mem;
>> -     }
>> +     if (n_buttons == 0)
>> +             return ERR_PTR(-ENODEV);
>
> But that one and the rest don't, because failure in
> soc_button_device_create() does not necessarily mean that binding for
> the whole device will fail. In this case we do not want unused memory
> hang around.
Agree. Should resend the patch with only the error check after mem
allocation and will be little more careful while sending any such
change. :)

>
> Thanks.
>
> --
> Dmitry



-- 
Thanks and Regards
Pramod

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

* Re: [PATCH v2] Input: soc_button_array: Remove kfree on data allocated with devm_zalloc
  2014-07-28  6:50   ` pramod gurav
@ 2014-07-28  7:10     ` Dmitry Torokhov
  2014-07-28  7:24       ` pramod gurav
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Torokhov @ 2014-07-28  7:10 UTC (permalink / raw)
  To: pramod gurav
  Cc: linux-input, linux-kernel, Pramod Gurav, Lejun Zhu, Sachin Kamat

On July 27, 2014 11:50:41 PM PDT, pramod gurav <pramod.gurav.etc@gmail.com> wrote:
>Hi Dmitry,
>
>Thanks for the review.
>
>On Fri, Jul 25, 2014 at 9:52 PM, Dmitry Torokhov
><dmitry.torokhov@gmail.com> wrote:
>> Hi Pramod,
>>
>> On Fri, Jul 25, 2014 at 05:04:34PM +0530, pramod.gurav.etc@gmail.com
>wrote:
>>> From: Pramod Gurav <pramod.gurav@smartplayin.com>
>>>
>>> This patch does below:
>>> - Removes kfree done on data allocated with devm_zalloc in probe
>>>   path of the driver.
>>> - Adds a check on return value from devm_kzalloc which was missing
>>>
>>> CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>>> CC: Lejun Zhu <lejun.zhu@linux.intel.com>
>>> CC: Sachin Kamat <sachin.kamat@linaro.org>
>>>
>>> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
>>> ---
>>>  drivers/input/misc/soc_button_array.c |   17 +++++++----------
>>>  1 file changed, 7 insertions(+), 10 deletions(-)
>>>
>>> diff --git a/drivers/input/misc/soc_button_array.c
>b/drivers/input/misc/soc_button_array.c
>>> index 5a6334b..fc64ec6 100644
>>> --- a/drivers/input/misc/soc_button_array.c
>>> +++ b/drivers/input/misc/soc_button_array.c
>>> @@ -83,6 +83,9 @@ soc_button_device_create(struct pnp_dev *pdev,
>>>                                      sizeof(*gpio_keys_pdata) +
>>>                                       sizeof(*gpio_keys) *
>MAX_NBUTTONS,
>>>                                      GFP_KERNEL);
>>> +     if (!gpio_keys_pdata)
>>> +             return ERR_PTR(-ENOMEM);
>>
>> OK, that makes sense.
>>
>>> +
>>>       gpio_keys = (void *)(gpio_keys_pdata + 1);
>>>
>>>       for (info = button_info; info->name; info++) {
>>> @@ -102,20 +105,16 @@ soc_button_device_create(struct pnp_dev *pdev,
>>>               n_buttons++;
>>>       }
>>>
>>> -     if (n_buttons == 0) {
>>> -             error = -ENODEV;
>>> -             goto err_free_mem;
>>> -     }
>>> +     if (n_buttons == 0)
>>> +             return ERR_PTR(-ENODEV);
>>
>> But that one and the rest don't, because failure in
>> soc_button_device_create() does not necessarily mean that binding for
>> the whole device will fail. In this case we do not want unused memory
>> hang around.
>Agree. Should resend the patch with only the error check after mem
>allocation and will be little more careful while sending any such
>change. :)

No need to resend, I picked out the good bits and applied.


Thanks.

-- 
Dmitry

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

* Re: [PATCH v2] Input: soc_button_array: Remove kfree on data allocated with devm_zalloc
  2014-07-28  7:10     ` Dmitry Torokhov
@ 2014-07-28  7:24       ` pramod gurav
  0 siblings, 0 replies; 8+ messages in thread
From: pramod gurav @ 2014-07-28  7:24 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, linux-kernel, Pramod Gurav, Lejun Zhu, Sachin Kamat

On Mon, Jul 28, 2014 at 12:40 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On July 27, 2014 11:50:41 PM PDT, pramod gurav <pramod.gurav.etc@gmail.com> wrote:
>>Hi Dmitry,
>>

>
> No need to resend, I picked out the good bits and applied.
Thanks. :)


-- 
Thanks and Regards
Pramod

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

* Re: [PATCH v2] Input: soc_button_array: Remove kfree on data allocated with devm_zalloc
  2014-07-25 10:29 ` Sachin Kamat
@ 2014-07-25 10:44   ` pramod gurav
  0 siblings, 0 replies; 8+ messages in thread
From: pramod gurav @ 2014-07-25 10:44 UTC (permalink / raw)
  To: Sachin Kamat
  Cc: linux-input, open list, Pramod Gurav, Dmitry Torokhov, Lejun Zhu,
	Sachin Kamat

On Fri, Jul 25, 2014 at 3:59 PM, Sachin Kamat <spk.linux@gmail.com> wrote:
> Hi Pramod,
>
>
> On Fri, Jul 25, 2014 at 2:42 PM,  <pramod.gurav.etc@gmail.com> wrote:
>> From: Pramod Gurav <pramod.gurav@smartplayin.com>
>>
>> This patch does below:
>> - Removes kfree done on data allocated with devm_zalloc in probe
>>   path of the driver.
>> - Adds a check on return value from devm_kzalloc which was missing
>> - Removes the error lables and instead releases resources and returns
>>   after failures
>>
>> CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> CC: Lejun Zhu <lejun.zhu@linux.intel.com>
>> CC: Sachin Kamat <sachin.kamat@linaro.org>
>>
>> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
>> ---
>>
>> Changes since v1:
>> - Removes de_err logs on OOM cases which is not needed.
>>
>>  drivers/input/misc/soc_button_array.c |   27 +++++++++++++++------------
>>  1 file changed, 15 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
>> index 5a6334b..f421cf4 100644
>> --- a/drivers/input/misc/soc_button_array.c
>> +++ b/drivers/input/misc/soc_button_array.c
>> @@ -83,6 +83,11 @@ soc_button_device_create(struct pnp_dev *pdev,
>>                                        sizeof(*gpio_keys_pdata) +
>>                                         sizeof(*gpio_keys) * MAX_NBUTTONS,
>>                                        GFP_KERNEL);
>> +       if (!gpio_keys_pdata) {
>> +               error = -ENOMEM;
>> +               return ERR_PTR(error);
>
> You don't need a variable here. You could directly do:
I tried to retain the original code as it is. I was not sure if am
supposed to do that. Wil do it now.

>                    return ERR_PTR(-ENOMEM);
>
>> +       }
>> +
>>         gpio_keys = (void *)(gpio_keys_pdata + 1);
>>
>>         for (info = button_info; info->name; info++) {
>> @@ -104,7 +109,7 @@ soc_button_device_create(struct pnp_dev *pdev,
>>
>>         if (n_buttons == 0) {
>>                 error = -ENODEV;
>> -               goto err_free_mem;
>> +               return ERR_PTR(error);
>
> ditto
>
>>         }
>>
>>         gpio_keys_pdata->buttons = gpio_keys;
>> @@ -114,25 +119,23 @@ soc_button_device_create(struct pnp_dev *pdev,
>>         pd = platform_device_alloc("gpio-keys", PLATFORM_DEVID_AUTO);
>>         if (!pd) {
>>                 error = -ENOMEM;
>> -               goto err_free_mem;
>> +               return ERR_PTR(error);
>
> ditto
>
>>         }
>>
>>         error = platform_device_add_data(pd, gpio_keys_pdata,
>>                                          sizeof(*gpio_keys_pdata));
>> -       if (error)
>> -               goto err_free_pdev;
>
> This goto could be retained to avoid code duplication.
If I keep this here, I have to handle the following returns in this
lable, which is what my previous patch was doing. So lable would look
something like this:

+err_free_pdev:
+      platform_device_put(pd);
+      return ERR_PTR(error);

>
>> +       if (error) {
>> +               platform_device_put(pd);
>> +               return ERR_PTR(error);
>> +       }
>>
>>         error = platform_device_add(pd);
>> -       if (error)
>> -               goto err_free_pdev;
>
> ditto
>
>> +       if (error) {
>> +               platform_device_put(pd);
>> +               return ERR_PTR(error);
>> +       }
>>
>>         return pd;
>> -
>> -err_free_pdev:
>> -       platform_device_put(pd);
>> -err_free_mem:
>> -       devm_kfree(&pdev->dev, gpio_keys_pdata);
>> -       return ERR_PTR(error);
>>  }
>>
>>  static void soc_button_remove(struct pnp_dev *pdev)
>> --
>> 1.7.9.5
>>
>
>
>
> --
> Regards,
> Sachin.



-- 
Thanks and Regards
Pramod

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

* Re: [PATCH v2] Input: soc_button_array: Remove kfree on data allocated with devm_zalloc
  2014-07-25  9:12 pramod.gurav.etc
@ 2014-07-25 10:29 ` Sachin Kamat
  2014-07-25 10:44   ` pramod gurav
  0 siblings, 1 reply; 8+ messages in thread
From: Sachin Kamat @ 2014-07-25 10:29 UTC (permalink / raw)
  To: pramod gurav
  Cc: linux-input, open list, Pramod Gurav, Dmitry Torokhov, Lejun Zhu,
	Sachin Kamat

Hi Pramod,


On Fri, Jul 25, 2014 at 2:42 PM,  <pramod.gurav.etc@gmail.com> wrote:
> From: Pramod Gurav <pramod.gurav@smartplayin.com>
>
> This patch does below:
> - Removes kfree done on data allocated with devm_zalloc in probe
>   path of the driver.
> - Adds a check on return value from devm_kzalloc which was missing
> - Removes the error lables and instead releases resources and returns
>   after failures
>
> CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> CC: Lejun Zhu <lejun.zhu@linux.intel.com>
> CC: Sachin Kamat <sachin.kamat@linaro.org>
>
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
> ---
>
> Changes since v1:
> - Removes de_err logs on OOM cases which is not needed.
>
>  drivers/input/misc/soc_button_array.c |   27 +++++++++++++++------------
>  1 file changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
> index 5a6334b..f421cf4 100644
> --- a/drivers/input/misc/soc_button_array.c
> +++ b/drivers/input/misc/soc_button_array.c
> @@ -83,6 +83,11 @@ soc_button_device_create(struct pnp_dev *pdev,
>                                        sizeof(*gpio_keys_pdata) +
>                                         sizeof(*gpio_keys) * MAX_NBUTTONS,
>                                        GFP_KERNEL);
> +       if (!gpio_keys_pdata) {
> +               error = -ENOMEM;
> +               return ERR_PTR(error);

You don't need a variable here. You could directly do:
                   return ERR_PTR(-ENOMEM);

> +       }
> +
>         gpio_keys = (void *)(gpio_keys_pdata + 1);
>
>         for (info = button_info; info->name; info++) {
> @@ -104,7 +109,7 @@ soc_button_device_create(struct pnp_dev *pdev,
>
>         if (n_buttons == 0) {
>                 error = -ENODEV;
> -               goto err_free_mem;
> +               return ERR_PTR(error);

ditto

>         }
>
>         gpio_keys_pdata->buttons = gpio_keys;
> @@ -114,25 +119,23 @@ soc_button_device_create(struct pnp_dev *pdev,
>         pd = platform_device_alloc("gpio-keys", PLATFORM_DEVID_AUTO);
>         if (!pd) {
>                 error = -ENOMEM;
> -               goto err_free_mem;
> +               return ERR_PTR(error);

ditto

>         }
>
>         error = platform_device_add_data(pd, gpio_keys_pdata,
>                                          sizeof(*gpio_keys_pdata));
> -       if (error)
> -               goto err_free_pdev;

This goto could be retained to avoid code duplication.

> +       if (error) {
> +               platform_device_put(pd);
> +               return ERR_PTR(error);
> +       }
>
>         error = platform_device_add(pd);
> -       if (error)
> -               goto err_free_pdev;

ditto

> +       if (error) {
> +               platform_device_put(pd);
> +               return ERR_PTR(error);
> +       }
>
>         return pd;
> -
> -err_free_pdev:
> -       platform_device_put(pd);
> -err_free_mem:
> -       devm_kfree(&pdev->dev, gpio_keys_pdata);
> -       return ERR_PTR(error);
>  }
>
>  static void soc_button_remove(struct pnp_dev *pdev)
> --
> 1.7.9.5
>



-- 
Regards,
Sachin.

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

* [PATCH v2] Input: soc_button_array: Remove kfree on data allocated with devm_zalloc
@ 2014-07-25  9:12 pramod.gurav.etc
  2014-07-25 10:29 ` Sachin Kamat
  0 siblings, 1 reply; 8+ messages in thread
From: pramod.gurav.etc @ 2014-07-25  9:12 UTC (permalink / raw)
  To: linux-input, linux-kernel
  Cc: Pramod Gurav, Dmitry Torokhov, Lejun Zhu, Sachin Kamat

From: Pramod Gurav <pramod.gurav@smartplayin.com>

This patch does below:
- Removes kfree done on data allocated with devm_zalloc in probe
  path of the driver.
- Adds a check on return value from devm_kzalloc which was missing
- Removes the error lables and instead releases resources and returns
  after failures

CC: Dmitry Torokhov <dmitry.torokhov@gmail.com>
CC: Lejun Zhu <lejun.zhu@linux.intel.com>
CC: Sachin Kamat <sachin.kamat@linaro.org>

Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
---

Changes since v1:
- Removes de_err logs on OOM cases which is not needed.

 drivers/input/misc/soc_button_array.c |   27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index 5a6334b..f421cf4 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -83,6 +83,11 @@ soc_button_device_create(struct pnp_dev *pdev,
 				       sizeof(*gpio_keys_pdata) +
 					sizeof(*gpio_keys) * MAX_NBUTTONS,
 				       GFP_KERNEL);
+	if (!gpio_keys_pdata) {
+		error = -ENOMEM;
+		return ERR_PTR(error);
+	}
+
 	gpio_keys = (void *)(gpio_keys_pdata + 1);
 
 	for (info = button_info; info->name; info++) {
@@ -104,7 +109,7 @@ soc_button_device_create(struct pnp_dev *pdev,
 
 	if (n_buttons == 0) {
 		error = -ENODEV;
-		goto err_free_mem;
+		return ERR_PTR(error);
 	}
 
 	gpio_keys_pdata->buttons = gpio_keys;
@@ -114,25 +119,23 @@ soc_button_device_create(struct pnp_dev *pdev,
 	pd = platform_device_alloc("gpio-keys", PLATFORM_DEVID_AUTO);
 	if (!pd) {
 		error = -ENOMEM;
-		goto err_free_mem;
+		return ERR_PTR(error);
 	}
 
 	error = platform_device_add_data(pd, gpio_keys_pdata,
 					 sizeof(*gpio_keys_pdata));
-	if (error)
-		goto err_free_pdev;
+	if (error) {
+		platform_device_put(pd);
+		return ERR_PTR(error);
+	}
 
 	error = platform_device_add(pd);
-	if (error)
-		goto err_free_pdev;
+	if (error) {
+		platform_device_put(pd);
+		return ERR_PTR(error);
+	}
 
 	return pd;
-
-err_free_pdev:
-	platform_device_put(pd);
-err_free_mem:
-	devm_kfree(&pdev->dev, gpio_keys_pdata);
-	return ERR_PTR(error);
 }
 
 static void soc_button_remove(struct pnp_dev *pdev)
-- 
1.7.9.5


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

end of thread, other threads:[~2014-07-28  7:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-25 11:34 [PATCH v2] Input: soc_button_array: Remove kfree on data allocated with devm_zalloc pramod.gurav.etc
2014-07-25 16:22 ` Dmitry Torokhov
2014-07-28  6:50   ` pramod gurav
2014-07-28  7:10     ` Dmitry Torokhov
2014-07-28  7:24       ` pramod gurav
  -- strict thread matches above, loose matches on Subject: below --
2014-07-25  9:12 pramod.gurav.etc
2014-07-25 10:29 ` Sachin Kamat
2014-07-25 10:44   ` pramod gurav

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.