USB: cdc-wdm: fix memory leak
authorOliver Neukum <oliver@neukum.org>
Fri, 27 Apr 2012 12:36:37 +0000 (14:36 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 30 May 2012 23:43:32 +0000 (00:43 +0100)
commit 2f338c8a1904e2e7aa5a8bd12fb0cf2422d17da4 upstream.

cleanup() is not called if the last close() comes after
disconnect(). That leads to a memory leak. Rectified
by checking for an earlier disconnect() in release()

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/class/cdc-wdm.c

index ac9099a..cfe5be4 100644 (file)
@@ -590,6 +590,8 @@ static int wdm_release(struct inode *inode, struct file *file)
                kill_urbs(desc);
                if (!test_bit(WDM_DISCONNECTING, &desc->flags))
                        desc->intf->needs_remote_wakeup = 0;
+               else
+                       cleanup(desc);
        }
        mutex_unlock(&wdm_mutex);
        return 0;