linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Neukum <oliver@neukum.org>
To: Jiri Kosina <jikos@jikos.cz>,
	linux-input@atrey.karlin.mff.cuni.cz,
	linux-usb-devel@lists.sourceforge.net
Subject: [PATCH]resource leak in hiddev if autoresume fails
Date: Fri, 5 Oct 2007 16:04:17 +0200	[thread overview]
Message-ID: <200710051604.18234.oliver@neukum.org> (raw)

Hi,

several resources are not freed if autoresume fails.

	Regards
		Oliver

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

----

--- a/drivers/hid/usbhid/hiddev.c	2007-10-05 15:42:45.000000000 +0200
+++ b/drivers/hid/usbhid/hiddev.c	2007-10-05 15:54:32.000000000 +0200
@@ -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/
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

                 reply	other threads:[~2007-10-05 14:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200710051604.18234.oliver@neukum.org \
    --to=oliver@neukum.org \
    --cc=jikos@jikos.cz \
    --cc=linux-input@atrey.karlin.mff.cuni.cz \
    --cc=linux-usb-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).