[PATCH] usb: dwc2: Fix memory leak in probe error path

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

 



The dwc2 driver private structure wasn't freed in the error path.

Signed-off-by: Jules Maselbas <jmaselbas@xxxxxxxxx>
---
 drivers/usb/dwc2/dwc2.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/dwc2/dwc2.c b/drivers/usb/dwc2/dwc2.c
index ef957534c9..ff4842ce62 100644
--- a/drivers/usb/dwc2/dwc2.c
+++ b/drivers/usb/dwc2/dwc2.c
@@ -92,11 +92,10 @@ static int dwc2_probe(struct device *dev)
 	set_params_cb set_params;
 	int ret;
 
-	dwc2 = xzalloc(sizeof(*dwc2));
-
 	iores = dev_request_mem_resource(dev, 0);
 	if (IS_ERR(iores))
 		return PTR_ERR(iores);
+	dwc2 = xzalloc(sizeof(*dwc2));
 	dwc2->regs = IOMEM(iores->start);
 	dwc2->dev = dev;
 
@@ -177,6 +176,8 @@ clk_put:
 release_region:
 	release_region(iores);
 
+	free(dwc2);
+
 	return ret;
 }
 
-- 
2.17.1





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux