Skip to contentSkip to conversation

resource leak in hiddev if autoresume fails

PATCH New Oliver Neukum 1 participant 1 message Oct 5, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 resource leak in hiddev if autoresume fails

Hi,

several resources are not freed if autoresume fails.

Regards
Oliver

----

drivers/hid/usbhid/hiddev.c +10 -7
@@ -280,18 +280,21 @@ static int hiddev_open(struct inode *ino
 
 	list->hiddev = hiddev_table[i];
 
-	spin_lock_irqsave(&list->hiddev->list_lock, flags);
-	list_add_tail(&list->node, &hiddev_table[i]->list);
-	spin_unlock_irqrestore(&list->hiddev->list_lock, flags);
-
-	file->private_data = list;
-
 	if (!list->hiddev->open++)
 		if (list->hiddev->exist) {
 			struct hid_device *hid = hiddev_table[i]->hid;
 			res = usbhid_get_power(hid);
-			if (res < 0)
+			if (res < 0) {
+				hiddev_table[i]->open--;
+				kfree(list);
 				return -EIO;
+			} else {
+				spin_lock_irqsave(&list->hiddev->list_lock, flags);
+				list_add_tail(&list->node, &hiddev_table[i]->list);
+				spin_unlock_irqrestore(&list->hiddev->list_lock, flags);
+
+				file->private_data = list;	
+			}
 			usbhid_open(hid);
 		}
 

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel