From patchwork Fri Jun 28 14:42:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralph Siemsen X-Patchwork-Id: 1124304 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="AUAyL5Y6"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45ZzyD0R37z9s3Z for ; Sat, 29 Jun 2019 00:42:43 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id ADB66C21E0B; Fri, 28 Jun 2019 14:42:35 +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 A93DFC21C8B; Fri, 28 Jun 2019 14:42:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 31A4CC21C57; Fri, 28 Jun 2019 14:42:32 +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 A7E87C21C2F for ; Fri, 28 Jun 2019 14:42:31 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id m24so13080204ioo.2 for ; Fri, 28 Jun 2019 07:42:31 -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:in-reply-to:references; bh=84Hi+FgEj3cvxiISO+dFs8c4AocwvmEbHWzHs9qAK7c=; b=AUAyL5Y61OEwvQKsw/J1lbKeEaE51gtcPoo9IjYHcNC6qbkXbP6exOPj7VQ29fKqcZ d7OjlL6vIFhsHrd4MIWJytB/bscsurfSy8wg6bGQuOZMkTJfj0LaYpfv1mOnJbrqajGC Rs74D7c8UnkalMt+RUcMsf4TDvXMlj+S96+rCTHA+gkDOvqw5KpuwJklBL9jBdt2FRy6 uKMLsNm0AXN8JoiM/AJbNIeDavyJ2djLzCVJwT9JgHgHgoRbADxgyMaQjwnxHub9b9x7 dY0/LsUZ7MIdlWiJEWS4zutj3snERRzJdU5GJqTisJHGavjWlpjUWMZE1pftM+ZWotm9 Jq+w== 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:in-reply-to :references; bh=84Hi+FgEj3cvxiISO+dFs8c4AocwvmEbHWzHs9qAK7c=; b=a5whe8IbhyN9VSBVy5aA8omaseF2GcC40h5JchJ39nxF3Xn7F/bCKZb+siZoo1qWl5 wieke4ZKyeC7IjPdeQLYse6pvzm729h1tM1Hwl0lFbdmUctr+Mi0GpHzvZP9U+/5pHvR LSKjwKLx2yxjhLdFXsuyDJRz87hlmkqzgI4KSqU5ZPd8s5TteJS7VRxxn9D1H8+GcPbc +9ZSD6Svj3/x3BRBTQmf5VLCyx9H2EVItW9S+TzrA5XDNcJlEpVGNlGnjtVw2vgjyLPO q2ujvTBej8QQMieM2+llT8Ss1p3OF+G00UrlEotARL1dExPpHH1zxr8jpOYL49m4DS3t IWAQ== X-Gm-Message-State: APjAAAWLqSZ6IEuTySWtFcIdjNdj6S6r5SA8F9gg3pcZ/Qk4hcnXa4Bd XYb0/YA+0kt2OpZfsg1IiHhG5ErOI1U= X-Google-Smtp-Source: APXvYqxKrVisJiDOEYlf+aRi0Chti5ZDHcP6SHzPZrbvUfy6NbTJRV+ikTCQXW+gs8ZLBLMGgRQO5Q== X-Received: by 2002:a6b:5103:: with SMTP id f3mr11399843iob.142.1561732950223; Fri, 28 Jun 2019 07:42:30 -0700 (PDT) Received: from maple.netwinder.org (rfs.netwinder.org. [206.248.184.2]) by smtp.gmail.com with ESMTPSA id c81sm5419201iof.28.2019.06.28.07.42.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 28 Jun 2019 07:42:29 -0700 (PDT) From: Ralph Siemsen To: u-boot@lists.denx.de Date: Fri, 28 Jun 2019 10:42:02 -0400 Message-Id: <20190628144202.27375-1-ralph.siemsen@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190627131632.6570-1-ralph.siemsen@linaro.org> References: <20190627131632.6570-1-ralph.siemsen@linaro.org> Subject: [U-Boot] [RESEND PATCH v2] 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 fails 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 --- Changes in v2: Remove incorrect note. Fix spelling error in commit message. 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;