public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 01/10] usb: gadget: don't leak configs when unbinding
@ 2015-09-05  4:03 Stephen Warren
  2015-09-05  4:03 ` [U-Boot] [PATCH 02/10] ext4: avoid calling ext4fs_mount() twice, which leaks Stephen Warren
                   ` (10 more replies)
  0 siblings, 11 replies; 34+ messages in thread
From: Stephen Warren @ 2015-09-05  4:03 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

By the time g_dnl_unbind() is run, cdev->config has been set to NULL,
so the free() there does nothing, and the config struct is leaked.
Equally, struct usb_gadget contains a linked list of config structs, so
the code should iterate over them all and free each one, rather than
freeing one particular config struct.

composite_unbind() already iterates over the list of config structs, and
unlinks each from the linked list. Fix this loop to free() each struct as
it's unlinked and otherwise forgotten.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 drivers/usb/gadget/composite.c | 1 +
 drivers/usb/gadget/g_dnl.c     | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index d96296cd73b1..a13b21d0a0f2 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -948,6 +948,7 @@ static void composite_unbind(struct usb_gadget *gadget)
 			debug("unbind config '%s'/%p\n", c->label, c);
 			c->unbind(c);
 		}
+		free(c);
 	}
 	if (composite->unbind)
 		composite->unbind(cdev);
diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
index ad89a0d2e670..2fa6da4091e1 100644
--- a/drivers/usb/gadget/g_dnl.c
+++ b/drivers/usb/gadget/g_dnl.c
@@ -93,8 +93,6 @@ static int g_dnl_unbind(struct usb_composite_dev *cdev)
 {
 	struct usb_gadget *gadget = cdev->gadget;
 
-	free(cdev->config);
-	cdev->config = NULL;
 	debug("%s: calling usb_gadget_disconnect for "
 			"controller '%s'\n", __func__, gadget->name);
 	usb_gadget_disconnect(gadget);
-- 
1.9.1

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

end of thread, other threads:[~2015-09-12 12:51 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-05  4:03 [U-Boot] [PATCH 01/10] usb: gadget: don't leak configs when unbinding Stephen Warren
2015-09-05  4:03 ` [U-Boot] [PATCH 02/10] ext4: avoid calling ext4fs_mount() twice, which leaks Stephen Warren
2015-09-08 13:22   ` Lukasz Majewski
2015-09-12 12:51   ` [U-Boot] [U-Boot, " Tom Rini
2015-09-05  4:03 ` [U-Boot] [PATCH 03/10] ext4: free allocations by parse_path() Stephen Warren
2015-09-08 13:10   ` Lukasz Majewski
2015-09-12 12:51   ` [U-Boot] [U-Boot,03/10] " Tom Rini
2015-09-05  4:03 ` [U-Boot] [PATCH 04/10] ext4: fix leak in check_filename() Stephen Warren
2015-09-08 13:05   ` Lukasz Majewski
2015-09-12 12:51   ` [U-Boot] [U-Boot,04/10] " Tom Rini
2015-09-05  4:03 ` [U-Boot] [PATCH 05/10] dfu: don't keep freeing/reallocating Stephen Warren
2015-09-08 12:32   ` Lukasz Majewski
2015-09-12 12:51   ` [U-Boot] [U-Boot,05/10] " Tom Rini
2015-09-05  4:03 ` [U-Boot] [PATCH 06/10] dfu: mmc: buffer file reads too Stephen Warren
2015-09-08 12:57   ` Lukasz Majewski
2015-09-12 12:51   ` [U-Boot] [U-Boot,06/10] " Tom Rini
2015-09-05  4:03 ` [U-Boot] [PATCH 07/10] ARM: tegra: fix malloc region sizing Stephen Warren
2015-09-08 16:53   ` Tom Warren
2015-09-08 21:45     ` Stephen Warren
2015-09-08 21:52       ` Stephen Warren
2015-09-08 21:56         ` Tom Rini
2015-09-08 21:56           ` Stephen Warren
2015-09-09  6:51         ` Lukasz Majewski
2015-09-09 16:08           ` Tom Warren
2015-09-12 12:51   ` [U-Boot] [U-Boot,07/10] " Tom Rini
2015-09-05  4:03 ` [U-Boot] [PATCH 08/10] ARM: tegra: tweak DFU buffer sizes Stephen Warren
2015-09-12 12:51   ` [U-Boot] [U-Boot,08/10] " Tom Rini
2015-09-05  4:03 ` [U-Boot] [PATCH 09/10] ARM: tegra: enable filesystem writing Stephen Warren
2015-09-12 12:51   ` [U-Boot] [U-Boot,09/10] " Tom Rini
2015-09-05  4:03 ` [U-Boot] [PATCH 10/10] ARM: tegra: enable DFU for RAM Stephen Warren
2015-09-12 12:51   ` [U-Boot] [U-Boot,10/10] " Tom Rini
2015-09-08 12:00 ` [U-Boot] [PATCH 01/10] usb: gadget: don't leak configs when unbinding Lukasz Majewski
2015-09-08 21:50   ` Stephen Warren
2015-09-12 12:51 ` [U-Boot] [U-Boot, " Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox