From: Nikita Kiryanov Date: Mon, 29 Jul 2013 10:27:40 +0000 (+0300) Subject: ehci-hcd: fix memory leak in lowlevel init X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=8bc3603675f7bf4dfa4eb6bdaf2aa0a8ddce9fa6;p=project%2Fbcm63xx%2Fu-boot.git ehci-hcd: fix memory leak in lowlevel init usb_lowlevel_init() allocates a new periodic_list each time it is invoked, without freeing the original list. Since it is initialized later on in the code, just reuse the first-allocated list in future invocations of usb_lowlevel_init. Cc: Marek Vasut Cc: Igor Grinberg Signed-off-by: Nikita Kiryanov --- diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c index 05d3f0bd53..fdad739724 100644 --- a/drivers/usb/host/ehci-hcd.c +++ b/drivers/usb/host/ehci-hcd.c @@ -945,7 +945,9 @@ int usb_lowlevel_init(int index, void **controller) * Split Transactions will be spread across microframes using * S-mask and C-mask. */ - ehcic[index].periodic_list = memalign(4096, 1024*4); + if (ehcic[index].periodic_list == NULL) + ehcic[index].periodic_list = memalign(4096, 1024 * 4); + if (!ehcic[index].periodic_list) return -ENOMEM; for (i = 0; i < 1024; i++) {