All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.4 01/17] usb: gadget: fotg210-udc: Fix memory leak of fotg210->ep[i]
@ 2018-10-01  0:41 Sasha Levin
  2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 03/17] perf probe powerpc: Ignore SyS symbols irrespective of endianness Sasha Levin
                   ` (15 more replies)
  0 siblings, 16 replies; 18+ messages in thread
From: Sasha Levin @ 2018-10-01  0:41 UTC (permalink / raw)
  To: stable, linux-kernel; +Cc: Anton Vasilyev, Felipe Balbi, Sasha Levin

From: Anton Vasilyev <vasilyev@ispras.ru>

[ Upstream commit c37bd52836296ecc9a0fc8060b819089aebdbcde ]

There is no deallocation of fotg210->ep[i] elements, allocated at
fotg210_udc_probe.

The patch adds deallocation of fotg210->ep array elements and simplifies
error path of fotg210_udc_probe().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Anton Vasilyev <vasilyev@ispras.ru>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/gadget/udc/fotg210-udc.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c
index 6ba122cc7490..95df2b3bb6a1 100644
--- a/drivers/usb/gadget/udc/fotg210-udc.c
+++ b/drivers/usb/gadget/udc/fotg210-udc.c
@@ -1066,12 +1066,15 @@ static struct usb_gadget_ops fotg210_gadget_ops = {
 static int fotg210_udc_remove(struct platform_device *pdev)
 {
 	struct fotg210_udc *fotg210 = platform_get_drvdata(pdev);
+	int i;
 
 	usb_del_gadget_udc(&fotg210->gadget);
 	iounmap(fotg210->reg);
 	free_irq(platform_get_irq(pdev, 0), fotg210);
 
 	fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req);
+	for (i = 0; i < FOTG210_MAX_NUM_EP; i++)
+		kfree(fotg210->ep[i]);
 	kfree(fotg210);
 
 	return 0;
@@ -1102,7 +1105,7 @@ static int fotg210_udc_probe(struct platform_device *pdev)
 	/* initialize udc */
 	fotg210 = kzalloc(sizeof(struct fotg210_udc), GFP_KERNEL);
 	if (fotg210 == NULL)
-		goto err_alloc;
+		goto err;
 
 	for (i = 0; i < FOTG210_MAX_NUM_EP; i++) {
 		_ep[i] = kzalloc(sizeof(struct fotg210_ep), GFP_KERNEL);
@@ -1114,7 +1117,7 @@ static int fotg210_udc_probe(struct platform_device *pdev)
 	fotg210->reg = ioremap(res->start, resource_size(res));
 	if (fotg210->reg == NULL) {
 		pr_err("ioremap error.\n");
-		goto err_map;
+		goto err_alloc;
 	}
 
 	spin_lock_init(&fotg210->lock);
@@ -1162,7 +1165,7 @@ static int fotg210_udc_probe(struct platform_device *pdev)
 	fotg210->ep0_req = fotg210_ep_alloc_request(&fotg210->ep[0]->ep,
 				GFP_KERNEL);
 	if (fotg210->ep0_req == NULL)
-		goto err_req;
+		goto err_map;
 
 	fotg210_init(fotg210);
 
@@ -1190,12 +1193,14 @@ static int fotg210_udc_probe(struct platform_device *pdev)
 	fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req);
 
 err_map:
-	if (fotg210->reg)
-		iounmap(fotg210->reg);
+	iounmap(fotg210->reg);
 
 err_alloc:
+	for (i = 0; i < FOTG210_MAX_NUM_EP; i++)
+		kfree(fotg210->ep[i]);
 	kfree(fotg210);
 
+err:
 	return ret;
 }
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2018-10-01  0:44 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01  0:41 [PATCH AUTOSEL 4.4 01/17] usb: gadget: fotg210-udc: Fix memory leak of fotg210->ep[i] Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 03/17] perf probe powerpc: Ignore SyS symbols irrespective of endianness Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 02/17] pinctrl: msm: Really mask level interrupts to prevent latching Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 04/17] RDMA/ucma: check fd type in ucma_migrate_id() Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 05/17] USB: yurex: Check for truncation in yurex_read() Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 06/17] drm/nouveau/TBDdevinit: don't fail when PMU/PRE_OS is missing from VBIOS Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 08/17] dm thin metadata: try to avoid ever aborting transactions Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 07/17] fs/cifs: suppress a string overflow warning Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 09/17] arch/hexagon: fix kernel/dma.c build warning Sasha Levin
2018-10-01  0:41   ` Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 10/17] hexagon: modify ffs() and fls() to return int Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 11/17] arm64: jump_label.h: use asm_volatile_goto macro instead of "asm goto" Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 12/17] r8169: Clear RTL_FLAG_TASK_*_PENDING when clearing RTL_FLAG_TASK_ENABLED Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 13/17] s390/qeth: don't dump past end of unknown HW header Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 14/17] cifs: read overflow in is_valid_oplock_break() Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 15/17] xen/manage: don't complain about an empty value in control/sysrq node Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 16/17] xen: avoid crash in disable_hotplug_cpu Sasha Levin
2018-10-01  0:41 ` [PATCH AUTOSEL 4.4 17/17] xen: fix GCC warning and remove duplicate EVTCHN_ROW/EVTCHN_COL usage Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.