mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC][PATCH 2.6.17-rc6] input/mouse/sermouse: fix memleak and potential buffer overflow
@ 2006-06-15 10:47 Wouter Paesen
  2006-06-18  4:24 ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Wouter Paesen @ 2006-06-15 10:47 UTC (permalink / raw)
  To: linux-kernel

While strolling trough the sermouse driver for some example code, I
noticed 2 strange things happening there :

* In the sermouse_connect function an input device structure is
  allocated (input_allocate_device), which is not deallocated 
  in the sermouse_disconnect function.  
  
  If I understand this correctly someone repeatedly connecting and 
  disconnecting the mouse would leak input_dev structures.

* In the sermouse_connect function the phys member of the sermouse 
  structure (32 characters) is initialised with :

     sprintf(sermouse->phys, "%s/input0", serio->phys);

  Because serio->phys is also a 32 character field the sprintf could
  result in 39 characters being written to the sermouse->phys.

If my understanding of both these concepts is correct, this is a patch
to fix the problems.

Signed-off-by: Wouter Paesen <wouter@kangaroot.net>

--- a/drivers/input/mouse/sermouse.c	2006-06-15 08:47:47.000000000 +0200
+++ b/drivers/input/mouse/sermouse.c	2006-06-15 08:52:13.000000000 +0200
@@ -53,7 +53,7 @@
 	unsigned char count;
 	unsigned char type;
 	unsigned long last;
-	char phys[32];
+	char phys[39];
 };
 
 /*
@@ -233,6 +233,7 @@
 	serio_close(serio);
 	serio_set_drvdata(serio, NULL);
 	input_unregister_device(sermouse->dev);
+	input_free_device(sermouse->dev);
 	kfree(sermouse);
 }

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

end of thread, other threads:[~2006-06-21 16:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-15 10:47 [RFC][PATCH 2.6.17-rc6] input/mouse/sermouse: fix memleak and potential buffer overflow Wouter Paesen
2006-06-18  4:24 ` Dmitry Torokhov
2006-06-20  6:41   ` Wouter Paesen
2006-06-21 16:23     ` Rolf Eike Beer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®