USB: cdc-wdm: fix memory leak
authorOliver Neukum <oliver@neukum.org>
Fri, 27 Apr 2012 12:36:37 +0000 (14:36 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 30 Apr 2012 01:53:41 +0000 (21:53 -0400)
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>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/class/cdc-wdm.c

index b29a9815e4d2f76c1c5b423e5dd18d3f52174afa..650e1da4d2bf89a44a9b0ee886107bf4916472f6 100644 (file)
@@ -622,6 +622,8 @@ static int wdm_release(struct inode *inode, struct file *file)
                kill_urbs(desc);
                if (!test_bit(WDM_DISCONNECTING, &desc->flags))
                        desc->manage_power(desc->intf, 0);
+               else
+                       cleanup(desc);
        }
        mutex_unlock(&wdm_mutex);
        return 0;