From patchwork Thu Jun 27 13:16:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralph Siemsen X-Patchwork-Id: 1123368 X-Patchwork-Delegate: lukma@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="NWeDvTKd"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45ZL9k0h7Kz9sNt for ; Thu, 27 Jun 2019 23:20:24 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 804FEC21E9F; Thu, 27 Jun 2019 13:19:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 89304C21E38; Thu, 27 Jun 2019 13:19:12 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 68DC2C21C2F; Thu, 27 Jun 2019 13:17:09 +0000 (UTC) Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by lists.denx.de (Postfix) with ESMTPS id B4148C21C29 for ; Thu, 27 Jun 2019 13:17:08 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id w25so4595102ioc.8 for ; Thu, 27 Jun 2019 06:17:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=OVfO6bNJ3edshyZRnxQB6zE/BX3NpBnqtHE0KP2LWIs=; b=NWeDvTKdu8a//IIAuESe+g+gXXa4unHTBU105h4nOJvDIoXNxr6vc0DJ9gSliqBxzO xcsGD/SbLjZxdXMVjwKhGMhK0ZXSnEY78rlmiXcSkxDkomwDdWwOUn8MIubmeBTvnnf3 3T2OQQbR77h9Z9eJo6xKwAunKiaQNzcut+u5YImfaST0S2r1fB9edmfYx5WXgIF20UXM lRB9mHE8EAxztnKZ7kCd5gr9CwlL5FF1SJGFZ0OwpzTSDFuOmD3dRpF9RNh4qUHrbzOn 6IiN38xjcZLS+BShnDeH8iPR97iXJLF4aqWFMPyZRSeYF1w4FpmievXvlxkY0SDfAckt 6oAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=OVfO6bNJ3edshyZRnxQB6zE/BX3NpBnqtHE0KP2LWIs=; b=Shzhwl0HCtA60WcpN3+WK4GCy+EED5/ofB7hdJ1dlNWC5jpyDJFdPwt5EyQtycOMfI qnQMyUrVo75lJw/+erPbSshUzwg94tuNlH0T/DtxfHAn+vIT6HnTOLB+O7/3kxy9Gy2s Do9QVhToqbt0LmSON0ziaG0LYw7UX8keqbdckU1ysOSW00Q1vC7eXqvwJ09CRWFEv5k+ qWg/HqfNHJI83sF4YwiNWSbHWikU1XU5q6eQ5B4DMmLTO3hFMQyOXN+qG4tc9yD8HQs0 sfjTF4HuiXHyUl00PwS83EJDfqn3cdBixb1kvA4w8uGWDnP4OHysH09oNk3cd6AV12AU 801A== X-Gm-Message-State: APjAAAUXjiZEAI/8j/LTvJ38xPzIk5aepvec7cjYgTvqaoIOtIAXeW2S cE1GQWKrwCKy2x/VHUcx15qDVM4qJqQ= X-Google-Smtp-Source: APXvYqxr0OyXruvfhReGbAKbd0HyoaDiB/kv/cGpmW/JRQ8oIQnD4uaj0diJLAYNLqKaGYDEs2FJhg== X-Received: by 2002:a6b:8d92:: with SMTP id p140mr4404274iod.144.1561641427322; Thu, 27 Jun 2019 06:17:07 -0700 (PDT) Received: from maple.netwinder.org (rfs.netwinder.org. [206.248.184.2]) by smtp.gmail.com with ESMTPSA id c10sm1873695ioh.58.2019.06.27.06.17.05 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 06:17:06 -0700 (PDT) From: Ralph Siemsen To: u-boot@lists.denx.de Date: Thu, 27 Jun 2019 09:16:32 -0400 Message-Id: <20190627131632.6570-1-ralph.siemsen@linaro.org> X-Mailer: git-send-email 2.17.1 X-Mailman-Approved-At: Thu, 27 Jun 2019 13:19:09 +0000 Subject: [U-Boot] [PATCH] usb: gadget: f_dfu.c: fix memory leak X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" dfu_prepare_function() allocates N+1 descriptor header structures, the last one being the "DFU Functional Descriptor". dfu_unbind() handles de-allocation, but failes to free the final one (eg. "DFU Functional Descriptor"), leading to memory leak. Fixed by incrementing counter, as in dfu_prepare_function(). Signed-off-by: Ralph Siemsen --- Notes: The array of pointers allocated in dfu_prepare_function() is larger than necessary. For some reason it is N+2 when N+1 would suffice. Not a memory leak, so did not address in this commit. drivers/usb/gadget/f_dfu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c index 30ece524a8..e27f146605 100644 --- a/drivers/usb/gadget/f_dfu.c +++ b/drivers/usb/gadget/f_dfu.c @@ -748,6 +748,7 @@ static void dfu_unbind(struct usb_configuration *c, struct usb_function *f) if (f_dfu->function) { i = alt_num; + i++; /* free DFU Functional Descriptor */ while (i) { free(f_dfu->function[--i]); f_dfu->function[i] = NULL;