linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch]fix memleak in error case of hiddev
@ 2008-10-31  9:31 Oliver Neukum
  2008-10-31 14:08 ` Jiri Kosina
  0 siblings, 1 reply; 8+ messages in thread
From: Oliver Neukum @ 2008-10-31  9:31 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Dmitry Torokhov, linux-input

Hi,

this bug is old, the patch should go into 2.6.28 and stable.

This fixes a memleak in hiddev's open in an error case.

Signed-off-by: Oliver Neukum <oneukum@suse.de>

	Regards
		Oliver

---

diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index b218cbc..6834d1f 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -291,8 +291,13 @@ static int hiddev_open(struct inode *inode, struct file *file)
 		if (list->hiddev->exist) {
 			struct hid_device *hid = hiddev_table[i]->hid;
 			res = usbhid_get_power(hid);
-			if (res < 0)
+			if (res < 0) {
+				spin_lock_irqsave(&list->hiddev->list_lock, flags);
+				list_del(&list->node);
+				spin_unlock_irqrestore(&list->hiddev->list_lock, flags);
+				kfree(list->hiddev);
 				return -EIO;
+			}
 			usbhid_open(hid);
 		}
 

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

end of thread, other threads:[~2008-11-12 15:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-31  9:31 [patch]fix memleak in error case of hiddev Oliver Neukum
2008-10-31 14:08 ` Jiri Kosina
2008-10-31 14:42   ` Oliver Neukum
2008-10-31 15:10   ` Oliver Neukum
2008-11-12 14:48     ` Jiri Kosina
2008-11-12 14:55       ` Oliver Neukum
2008-11-12 14:56         ` Jiri Kosina
2008-11-12 15:11         ` Jiri Slaby

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