From 2f338c8a1904e2e7aa5a8bd12fb0cf2422d17da4 Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Fri, 27 Apr 2012 14:36:37 +0200 Subject: [PATCH] USB: cdc-wdm: fix memory leak 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 Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/cdc-wdm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c index b29a9815e4d2..650e1da4d2bf 100644 --- a/drivers/usb/class/cdc-wdm.c +++ b/drivers/usb/class/cdc-wdm.c @@ -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; -- 2.20.1