linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input: psmouse: fix input_dev leak in lifebook driver
@ 2008-01-12 20:12 Andres Salomon
  2008-01-15 22:04 ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Andres Salomon @ 2008-01-12 20:12 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: dtor, linux-input, Andrew Morton, linux-kernel


The lifebook driver may register a second input device, but it never
unregisters it.  This fixes that.

Signed-off-by: Andres Salomon <dilinger@debian.org>
---
 drivers/input/mouse/lifebook.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/input/mouse/lifebook.c b/drivers/input/mouse/lifebook.c
index 9ec57d8..df81b0a 100644
--- a/drivers/input/mouse/lifebook.c
+++ b/drivers/input/mouse/lifebook.c
@@ -225,8 +225,13 @@ static void lifebook_set_resolution(struct psmouse *psmouse, unsigned int resolu
 
 static void lifebook_disconnect(struct psmouse *psmouse)
 {
+	struct lifebook_data *priv = psmouse->private;
+
 	psmouse_reset(psmouse);
-	kfree(psmouse->private);
+	if (priv) {
+		input_unregister_device(priv->dev2);
+		kfree(priv);
+	}
 	psmouse->private = NULL;
 }
 
-- 
1.5.3.5


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

* Re: [PATCH] input: psmouse: fix input_dev leak in lifebook driver
  2008-01-12 20:12 [PATCH] input: psmouse: fix input_dev leak in lifebook driver Andres Salomon
@ 2008-01-15 22:04 ` Dmitry Torokhov
  2008-01-16 17:58   ` Andres Salomon
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2008-01-15 22:04 UTC (permalink / raw)
  To: Andres Salomon; +Cc: linux-input, Andrew Morton, linux-kernel

On Sat, Jan 12, 2008 at 03:12:52PM -0500, Andres Salomon wrote:
> 
> The lifebook driver may register a second input device, but it never
> unregisters it.  This fixes that.
> 
> Signed-off-by: Andres Salomon <dilinger@debian.org>

Applied, thank you Andres.

-- 
Dmitry


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

* Re: [PATCH] input: psmouse: fix input_dev leak in lifebook driver
  2008-01-15 22:04 ` Dmitry Torokhov
@ 2008-01-16 17:58   ` Andres Salomon
  2008-01-16 19:15     ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Andres Salomon @ 2008-01-16 17:58 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-kernel

On Tue, 15 Jan 2008 17:04:01 -0500
Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:

> On Sat, Jan 12, 2008 at 03:12:52PM -0500, Andres Salomon wrote:
> > 
> > The lifebook driver may register a second input device, but it never
> > unregisters it.  This fixes that.
> > 
> > Signed-off-by: Andres Salomon <dilinger@debian.org>
> 
> Applied, thank you Andres.
>

Hi Dmitry,
 
There's one additional patch, I don't know if you saw it; the subject
was "check return value of input_register_device() in hil_ptr.c's init".


Also, I've found myself needing to provide my own device_attribute for
the OLPC psmouse driver; I couldn't use PSMOUSE_DEFINE_ATTR(), as its
set_helper callback calls psmouse_disable.

static DEVICE_ATTR(powered, S_IWUSR | S_IRUGO, hgpk_show_powered,
                hgpk_set_powered);

Unfortunately, in order to not be racy, hgpk_set_powered needs to
deal with psmouse_mutex.  Which method of dealing with this would
you prefer?  I could either make psmouse_mutex no longer static,
provide psmouse_mutex locking functions (declared in psmouse.h), or
put psmouse_mutex into 'struct psmouse'.  Or, if you have any other
ideas..


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

* Re: [PATCH] input: psmouse: fix input_dev leak in lifebook driver
  2008-01-16 17:58   ` Andres Salomon
@ 2008-01-16 19:15     ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2008-01-16 19:15 UTC (permalink / raw)
  To: Andres Salomon; +Cc: linux-input, linux-kernel

On Wed, Jan 16, 2008 at 12:58:01PM -0500, Andres Salomon wrote:
> On Tue, 15 Jan 2008 17:04:01 -0500
> Dmitry Torokhov <dmitry.torokhov@gmail.com> wrote:
> 
> > On Sat, Jan 12, 2008 at 03:12:52PM -0500, Andres Salomon wrote:
> > > 
> > > The lifebook driver may register a second input device, but it never
> > > unregisters it.  This fixes that.
> > > 
> > > Signed-off-by: Andres Salomon <dilinger@debian.org>
> > 
> > Applied, thank you Andres.
> >
> 
> Hi Dmitry,
>  
> There's one additional patch, I don't know if you saw it; the subject
> was "check return value of input_register_device() in hil_ptr.c's init".
> 

I have seen it but postponed for later. Right now I am trying to get though
2.6.24 material.

> 
> Also, I've found myself needing to provide my own device_attribute for
> the OLPC psmouse driver; I couldn't use PSMOUSE_DEFINE_ATTR(), as its
> set_helper callback calls psmouse_disable.
> 
> static DEVICE_ATTR(powered, S_IWUSR | S_IRUGO, hgpk_show_powered,
>                 hgpk_set_powered);
> 
> Unfortunately, in order to not be racy, hgpk_set_powered needs to
> deal with psmouse_mutex.  Which method of dealing with this would
> you prefer?  I could either make psmouse_mutex no longer static,
> provide psmouse_mutex locking functions (declared in psmouse.h), or
> put psmouse_mutex into 'struct psmouse'.  Or, if you have any other
> ideas..

Could you just send me the code? I tend to think better when I see it...

Thanks!

-- 
Dmitry

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

end of thread, other threads:[~2008-01-16 19:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-12 20:12 [PATCH] input: psmouse: fix input_dev leak in lifebook driver Andres Salomon
2008-01-15 22:04 ` Dmitry Torokhov
2008-01-16 17:58   ` Andres Salomon
2008-01-16 19:15     ` Dmitry Torokhov

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).