From: Courtney Cavin <courtney.cavin@sonymobile.com>
To: Christopher Heiny <cheiny@synaptics.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Linux Input <linux-input@vger.kernel.org>,
Andrew Duggan <aduggan@synaptics.com>,
Vincent Huang <vincent.huang@tw.synaptics.com>,
Vivian Ly <vly@synaptics.com>,
Daniel Rosenberg <daniel.rosenberg@synaptics.com>,
Jean Delvare <khali@linux-fr.org>,
Joerie de Gram <j.de.gram@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
David Herrmann <dh.herrmann@gmail.com>,
Jiri Kosina <jkosina@suse.cz>
Subject: Re: [PATCH] input synaptics-rmi4: rmi_f01.c storage fix
Date: Tue, 11 Feb 2014 17:26:06 -0800 [thread overview]
Message-ID: <20140212012606.GY1706@sonymobile.com> (raw)
In-Reply-To: <1392160380-8221-1-git-send-email-cheiny@synaptics.com>
On Wed, Feb 12, 2014 at 12:13:00AM +0100, Christopher Heiny wrote:
> Correctly free driver related data when initialization fails.
>
> Trivial: Clarify a diagnostic message.
>
> Signed-off-by: Christopher Heiny <cheiny@synaptics.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> Cc: Linux Walleij <linus.walleij@linaro.org>
> Cc: David Herrmann <dh.herrmann@gmail.com>
> Cc: Jiri Kosina <jkosina@suse.cz>
>
> ---
>
> drivers/input/rmi4/rmi_f01.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c
> index 381ad60..e4a6df9 100644
> --- a/drivers/input/rmi4/rmi_f01.c
> +++ b/drivers/input/rmi4/rmi_f01.c
> @@ -149,7 +149,7 @@ static int rmi_f01_alloc_memory(struct rmi_function *fn,
>
> f01 = devm_kzalloc(&fn->dev, sizeof(struct f01_data), GFP_KERNEL);
> if (!f01) {
> - dev_err(&fn->dev, "Failed to allocate fn_01_data.\n");
> + dev_err(&fn->dev, "Failed to allocate f01_data.\n");
Just remove this printout, as it won't help any user in the case of OOM.
Additionally, there's already plenty of (more useful) information
printed out if kmalloc fails.
> return -ENOMEM;
> }
>
> @@ -158,6 +158,7 @@ static int rmi_f01_alloc_memory(struct rmi_function *fn,
> GFP_KERNEL);
> if (!f01->device_control.interrupt_enable) {
> dev_err(&fn->dev, "Failed to allocate interrupt enable.\n");
> + devm_kfree(&fn->dev, f01);
Unnecessary, devres_release_all() will release this, from:
- really_probe() -> rmi_function_probe() -> rmi_f01_probe()
- driver_probe_device()
- __driver_attach()
- driver_attach()
- bus_add_driver()
- driver_register()
- __rmi_register_function_handler()
> return -ENOMEM;
> }
> fn->data = f01;
> @@ -381,7 +382,8 @@ static int rmi_f01_initialize(struct rmi_function *fn)
> return 0;
>
> error_exit:
> - kfree(data);
> + devm_kfree(&fn->dev, data->device_control.interrupt_enable);
> + devm_kfree(&fn->dev, data);
Same as above for these two.
> return error;
> }
>
Generally devm_ release functions are unnecessary to call, as all
resources will get released on driver detach, whether abnormal or not.
-Courtney
next prev parent reply other threads:[~2014-02-12 1:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-11 23:13 [PATCH] input synaptics-rmi4: rmi_f01.c storage fix Christopher Heiny
2014-02-12 1:26 ` Courtney Cavin [this message]
2014-02-12 3:03 ` Christopher Heiny
2014-02-12 6:40 ` Dmitry Torokhov
2014-02-12 21:48 ` Courtney Cavin
2014-02-12 23:21 ` Christopher Heiny
2014-02-12 23:35 ` Courtney Cavin
2014-02-12 23:28 ` Dmitry Torokhov
2014-02-13 0:04 ` Courtney Cavin
2014-02-12 23:08 ` Christopher Heiny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140212012606.GY1706@sonymobile.com \
--to=courtney.cavin@sonymobile.com \
--cc=aduggan@synaptics.com \
--cc=benjamin.tissoires@redhat.com \
--cc=cheiny@synaptics.com \
--cc=daniel.rosenberg@synaptics.com \
--cc=dh.herrmann@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=j.de.gram@gmail.com \
--cc=jkosina@suse.cz \
--cc=khali@linux-fr.org \
--cc=linus.walleij@linaro.org \
--cc=linux-input@vger.kernel.org \
--cc=vincent.huang@tw.synaptics.com \
--cc=vly@synaptics.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.