[patch]fix memleak in error case of hiddev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>

	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);
 		}
 
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux