Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759887AbaGYItA (ORCPT ); Fri, 25 Jul 2014 04:49:00 -0400 Received: from mail-la0-f45.google.com ([209.85.215.45]:33354 "EHLO mail-la0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755177AbaGYIs5 (ORCPT ); Fri, 25 Jul 2014 04:48:57 -0400 MIME-Version: 1.0 In-Reply-To: References: <1406272180-25101-1-git-send-email-pramod.gurav@smartplayin.com> Date: Fri, 25 Jul 2014 14:18:55 +0530 Message-ID: Subject: Re: [PATCH] Input: soc_button_array: Remove kfree on data allocated with devm_zalloc From: pramod gurav To: Sachin Kamat Cc: linux-input@vger.kernel.org, open list , Pramod Gurav , Dmitry Torokhov , Lejun Zhu , Sachin Kamat Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks Sachin for the review. Will resend the patch addressing your review comments. On Fri, Jul 25, 2014 at 1:59 PM, Sachin Kamat wrote: > On Fri, Jul 25, 2014 at 12:39 PM, wrote: >> From: Pramod Gurav >> >> 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 >> and renames a lable from err_free_mem to err_mem. >> - Adds couple of dev_err on failure to allocate memory >> >> CC: Dmitry Torokhov >> CC: Lejun Zhu >> CC: Sachin Kamat >> >> Signed-off-by: Pramod Gurav >> --- >> drivers/input/misc/soc_button_array.c | 19 ++++++++++++++----- >> 1 file changed, 14 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c >> index 5a6334b..ac82971 100644 >> --- a/drivers/input/misc/soc_button_array.c >> +++ b/drivers/input/misc/soc_button_array.c >> @@ -83,6 +83,13 @@ soc_button_device_create(struct pnp_dev *pdev, >> sizeof(*gpio_keys_pdata) + >> sizeof(*gpio_keys) * MAX_NBUTTONS, >> GFP_KERNEL); >> + if (!gpio_keys_pdata) { >> + dev_err(&pdev->dev, >> + "Can't allocate memory for gpio_keys_platform_data\n"); > > OOM message is not needed as memory subsystem will take care of it. > >> + error = -ENOMEM; >> + goto err_mem; > > Return directly from here. > >> + } >> + >> gpio_keys = (void *)(gpio_keys_pdata + 1); >> >> for (info = button_info; info->name; info++) { >> @@ -104,7 +111,7 @@ soc_button_device_create(struct pnp_dev *pdev, >> >> if (n_buttons == 0) { >> error = -ENODEV; >> - goto err_free_mem; >> + goto err_mem; > > ditto > >> } >> >> gpio_keys_pdata->buttons = gpio_keys; >> @@ -114,7 +121,7 @@ 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; >> + goto err_mem; > > ditto > >> } >> >> error = platform_device_add_data(pd, gpio_keys_pdata, >> @@ -130,8 +137,7 @@ 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); >> +err_mem: > > This label would not be required once returned directly from above. > >> return ERR_PTR(error); >> } >> >> @@ -155,8 +161,11 @@ static int soc_button_pnp_probe(struct pnp_dev *pdev, >> int error; >> >> priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); >> - if (!priv) >> + if (!priv) { >> + dev_err(&pdev->dev, >> + "Can't allocate memory for soc_button_data\n"); > > OOM message is not needed as memory subsystem will take care of it. > > > -- > Regards, > Sachin. -- Thanks and Regards Pramod -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/