[PATCH v3] usb: dwc3: fix memory leak of dwc->regset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Du, Changbin" <changbin.du@xxxxxxxxx>

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@xxxxxxxxx>
---
v3:
  remove unnecessary if(!NULL) for free
v2:
  Title changed;
  free dwc->regset on failure path.
---
 drivers/usb/dwc3/debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c
index 9ac37fe..07d99eb 100644
--- a/drivers/usb/dwc3/debugfs.c
+++ b/drivers/usb/dwc3/debugfs.c
@@ -678,7 +678,7 @@ int dwc3_debugfs_init(struct dwc3 *dwc)
 
 err1:
 	debugfs_remove_recursive(root);
-
+	kfree(dwc->regset);
 err0:
 	return ret;
 }
@@ -686,5 +686,5 @@ err0:
 void dwc3_debugfs_exit(struct dwc3 *dwc)
 {
 	debugfs_remove_recursive(dwc->root);
-	dwc->root = NULL;
+	kfree(dwc->regset);
 }
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux