lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <87h9f7kujj.fsf@intel.com>
Date:	Tue, 12 Apr 2016 13:09:36 +0300
From:	Felipe Balbi <balbi@...nel.org>
To:	changbin.du@...el.com
Cc:	gregkh@...uxfoundation.org, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	"Du\, Changbin" <changbin.du@...el.com>
Subject: Re: [PATCH v3] usb: dwc3: fix memory leak of dwc->regset


Hi,

changbin.du@...el.com writes:
> From: "Du, Changbin" <changbin.du@...el.com>
>
> dwc->regset is allocated on dwc3_debugfs_init, and should
> be released on init failure or dwc3_debugfs_exit. Btw,
> The line "dwc->root = NULL" is unnecessary, so remove it.
>
> Signed-off-by: Du, Changbin <changbin.du@...el.com>
> ---

I've modifed the patch a little bit just to make sure the error labels
are easy to follow:

commit c7232c5fdcc5e1b6fc39b498b58573553ebb43da
Author: Du, Changbin <changbin.du@...el.com>
Date:   Tue Apr 12 16:24:34 2016 +0800

    usb: dwc3: fix memory leak of dwc->regset
    
    dwc->regset is allocated on dwc3_debugfs_init, and should
    be released on init failure or dwc3_debugfs_exit. Btw,
    The line "dwc->root = NULL" is unnecessary, so remove it.
    
    Signed-off-by: Du, Changbin <changbin.du@...el.com>
    
    [ felipe.balbi@...ux.intel.com : add another err label for the new
    	error condition ]
    
    Signed-off-by: Felipe Balbi <felipe.balbi@...ux.intel.com>

diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
index 9ac37fe1b6a7..cebf9e38b60a 100644
--- a/drivers/usb/dwc3/debugfs.c
+++ b/drivers/usb/dwc3/debugfs.c
@@ -645,7 +645,7 @@ int dwc3_debugfs_init(struct dwc3 *dwc)
 	file = debugfs_create_regset32("regdump", S_IRUGO, root, dwc->regset);
 	if (!file) {
 		ret = -ENOMEM;
-		goto err1;
+		goto err2;
 	}
 
 	if (IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)) {
@@ -653,7 +653,7 @@ int dwc3_debugfs_init(struct dwc3 *dwc)
 				dwc, &dwc3_mode_fops);
 		if (!file) {
 			ret = -ENOMEM;
-			goto err1;
+			goto err2;
 		}
 	}
 
@@ -663,19 +663,22 @@ int dwc3_debugfs_init(struct dwc3 *dwc)
 				dwc, &dwc3_testmode_fops);
 		if (!file) {
 			ret = -ENOMEM;
-			goto err1;
+			goto err2;
 		}
 
 		file = debugfs_create_file("link_state", S_IRUGO | S_IWUSR, root,
 				dwc, &dwc3_link_state_fops);
 		if (!file) {
 			ret = -ENOMEM;
-			goto err1;
+			goto err2;
 		}
 	}
 
 	return 0;
 
+err2:
+	kfree(dwc->regset);
+
 err1:
 	debugfs_remove_recursive(root);
 
@@ -686,5 +689,5 @@ err0:
 void dwc3_debugfs_exit(struct dwc3 *dwc)
 {
 	debugfs_remove_recursive(dwc->root);
-	dwc->root = NULL;
+	kfree(dwc->regset);
 }

patch is longer but functionally equivalent.

-- 
balbi

Download attachment "signature.asc" of type "application/pgp-signature" (819 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ