From: Courtney Cavin <courtney.cavin@sonymobile.com>
To: Christopher Heiny <cheiny@synaptics.com>
Cc: "linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
"dmitry.torokhov@gmail.com" <dmitry.torokhov@gmail.com>,
linus.walleij@stericsson.com, linus.walleij@linaro.org
Subject: Re: [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly
Date: Tue, 4 Feb 2014 18:28:51 -0800 [thread overview]
Message-ID: <20140205022851.GC1706@sonymobile.com> (raw)
In-Reply-To: <52F172E8.9040203@synaptics.com>
On Wed, Feb 05, 2014 at 12:08:24AM +0100, Christopher Heiny wrote:
> On 01/23/2014 04:00 PM, Courtney Cavin wrote:
> > Devices use a kobject to manage references, do not delete the memory
> > while still referenced. Instead, call put_device() to release the
> > reference.
>
> This is an interesting idea, but it should be done consistently for all
> the device types.
>
This is not an idea, just a bugfix. The kernel will segfault on failure
in which results in the kfree(). I didn't notice any other
device_register() calls which have this particular issue, but I might
have missed something.
> >
> > Cc: Christopher Heiny <cheiny@synaptics.com>
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Signed-off-by: Courtney Cavin <courtney.cavin@sonymobile.com>
> > ---
> > drivers/input/rmi4/rmi_bus.c | 8 +++++---
> > drivers/input/rmi4/rmi_driver.c | 6 +-----
> > 2 files changed, 6 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
> > index 8a939f3..cd7bfbd 100644
> > --- a/drivers/input/rmi4/rmi_bus.c
> > +++ b/drivers/input/rmi4/rmi_bus.c
> > @@ -94,8 +94,7 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
> > return -EINVAL;
> > }
> >
> > - rmi_dev = devm_kzalloc(xport->dev,
> > - sizeof(struct rmi_device), GFP_KERNEL);
> > + rmi_dev = kzalloc(sizeof(struct rmi_device), GFP_KERNEL);
> > if (!rmi_dev)
> > return -ENOMEM;
> >
> > @@ -112,8 +111,10 @@ int rmi_register_transport_device(struct rmi_transport_dev *xport)
> > rmi_physical_setup_debugfs(rmi_dev);
> >
> > error = device_register(&rmi_dev->dev);
> > - if (error)
> > + if (error) {
> > + put_device(&rmi_dev->dev);
> > return error;
> > + }
> >
> > dev_dbg(xport->dev, "%s: Registered %s as %s.\n", __func__,
> > pdata->sensor_name, dev_name(&rmi_dev->dev));
> > @@ -240,6 +241,7 @@ int rmi_register_function(struct rmi_function *fn)
> > dev_err(&rmi_dev->dev,
> > "Failed device_register function device %s\n",
> > dev_name(&fn->dev));
> > + put_device(&fn->dev);
> > goto error_exit;
> > }
> >
> > diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c
> > index 5c6379c..4965589 100644
> > --- a/drivers/input/rmi4/rmi_driver.c
> > +++ b/drivers/input/rmi4/rmi_driver.c
> > @@ -557,15 +557,11 @@ static int create_function(struct rmi_device *rmi_dev,
> >
> > error = rmi_register_function(fn);
> > if (error)
> > - goto err_free_mem;
> > + return error;
> >
> > list_add_tail(&fn->node, &data->function_list);
> >
> > return 0;
> > -
> > -err_free_mem:
> > - kfree(fn);
> > - return error;
> > }
> >
> > /*
> >
next prev parent reply other threads:[~2014-02-05 2:27 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-24 0:00 [PATCH 00/15] Input: synaptics-rmi4 - cleanup and add DT support Courtney Cavin
2014-01-24 0:00 ` [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings Courtney Cavin
2014-01-24 0:00 ` [PATCH 02/15] Input: synaptics-rmi4 - don't kfree devm_ alloced memory Courtney Cavin
2014-01-24 0:00 ` [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly Courtney Cavin
2014-01-24 0:00 ` [PATCH 04/15] Input: synaptics-rmi4 - remove sensor name from platform data Courtney Cavin
2014-01-24 0:00 ` [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling Courtney Cavin
2014-01-24 0:00 ` [PATCH 06/15] Input: synaptics-rmi4 - remove platform suspend callbacks Courtney Cavin
2014-01-24 0:00 ` [PATCH 07/15] Input: synaptics-rmi4 - remove remaining debugfs code Courtney Cavin
2014-01-24 0:00 ` [PATCH 08/15] Input: synaptics-rmi4 - cleanup platform data Courtney Cavin
2014-01-24 0:00 ` [PATCH 09/15] Input: synaptics-rmi4 - remove unused defines and variables Courtney Cavin
2014-01-24 0:00 ` [PATCH 10/15] Input: synaptics-rmi4 - add devicetree support Courtney Cavin
2014-01-24 0:00 ` [PATCH 11/15] Input: synaptics-rmi4 - add regulator support Courtney Cavin
2014-01-24 0:00 ` [PATCH 12/15] Input: synaptics-rmi4 - don't immediately set page on probe Courtney Cavin
2014-01-24 0:00 ` [PATCH 13/15] Input: synaptics-rmi4 - properly set F01 container on PDT scan Courtney Cavin
2014-01-24 0:00 ` [PATCH 14/15] Input: synaptics-rmi4 - ensure we have IRQs before reading status Courtney Cavin
2014-01-24 0:00 ` [PATCH 15/15] Input: synaptics-rmi4 - correct RMI4 spec url Courtney Cavin
2014-02-04 23:10 ` Christopher Heiny
2014-02-06 1:14 ` Dmitry Torokhov
2014-02-04 23:10 ` [PATCH 14/15] Input: synaptics-rmi4 - ensure we have IRQs before reading status Christopher Heiny
2014-02-05 2:40 ` Courtney Cavin
2014-02-04 23:10 ` [PATCH 13/15] Input: synaptics-rmi4 - properly set F01 container on PDT scan Christopher Heiny
2014-02-05 2:39 ` Courtney Cavin
2014-02-04 23:10 ` [PATCH 11/15] Input: synaptics-rmi4 - add regulator support Christopher Heiny
2014-02-05 2:38 ` Courtney Cavin
2014-02-04 23:10 ` [PATCH 10/15] Input: synaptics-rmi4 - add devicetree support Christopher Heiny
2014-02-05 2:37 ` Courtney Cavin
2014-02-04 23:10 ` [PATCH 09/15] Input: synaptics-rmi4 - remove unused defines and variables Christopher Heiny
2014-02-05 2:35 ` Courtney Cavin
2014-02-04 23:10 ` [PATCH 08/15] Input: synaptics-rmi4 - cleanup platform data Christopher Heiny
2014-02-05 2:34 ` Courtney Cavin
2014-02-04 23:09 ` [PATCH 07/15] Input: synaptics-rmi4 - remove remaining debugfs code Christopher Heiny
2014-02-05 2:33 ` Courtney Cavin
2014-02-04 23:09 ` [PATCH 06/15] Input: synaptics-rmi4 - remove platform suspend callbacks Christopher Heiny
2014-02-05 2:32 ` Courtney Cavin
2014-02-04 23:08 ` [PATCH 05/15] Input: synaptics-rmi4 - remove gpio handling and polling Christopher Heiny
2014-02-05 2:31 ` Courtney Cavin
2014-02-06 9:28 ` Linus Walleij
2014-02-06 20:05 ` Christopher Heiny
2014-02-07 1:45 ` Courtney Cavin
2014-02-06 20:05 ` Christopher Heiny
2014-02-07 1:47 ` Courtney Cavin
2014-02-04 23:08 ` [PATCH 04/15] Input: synaptics-rmi4 - remove sensor name from platform data Christopher Heiny
2014-02-05 2:30 ` Courtney Cavin
2014-02-04 23:08 ` [PATCH 03/15] Input: synaptics-rmi4 - don't free devices directly Christopher Heiny
2014-02-05 2:28 ` Courtney Cavin [this message]
2014-02-04 23:08 ` [PATCH 02/15] Input: synaptics-rmi4 - don't kfree devm_ alloced memory Christopher Heiny
2014-02-05 2:27 ` Courtney Cavin
2014-02-04 23:08 ` [PATCH 01/15] Input: synaptics-rmi4 - fix checkpatch.pl, sparse and GCC warnings Christopher Heiny
2014-02-05 2:26 ` Courtney Cavin
2014-02-06 1:09 ` Dmitry Torokhov
2014-02-06 1:36 ` Christopher Heiny
2014-02-13 6:36 ` Dmitry Torokhov
2014-02-13 18:56 ` Christopher Heiny
2014-02-13 19:10 ` Dmitry Torokhov
2014-02-13 19:12 ` Dmitry Torokhov
2014-02-13 19:25 ` Christopher Heiny
2014-01-24 0:06 ` [PATCH 00/15] Input: synaptics-rmi4 - cleanup and add DT support Courtney Cavin
2014-01-24 23:24 ` Christopher Heiny
2014-01-25 1:08 ` Courtney Cavin
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=20140205022851.GC1706@sonymobile.com \
--to=courtney.cavin@sonymobile.com \
--cc=cheiny@synaptics.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linus.walleij@stericsson.com \
--cc=linux-input@vger.kernel.org \
/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.