Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7148748ybi; Mon, 8 Jul 2019 15:37:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3LvZIqW/ccgH8T1bOCgzbANXIxIEf+SMFlqg0SYY6ndGcWUS5q3g81aO5VBrv03xE3MT4 X-Received: by 2002:a63:3046:: with SMTP id w67mr27116984pgw.37.1562625440411; Mon, 08 Jul 2019 15:37:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625440; cv=none; d=google.com; s=arc-20160816; b=YsQfoT3gmViKGIslgAyPBQhsIFTmyHkuDtAGGSw90z49ieZwQ+E/aPmvK/c6e3018G R4GodXwBtVA2gL78roAGC7ItMpBbKmUSOaevWJMrQCR2k/XAGl8LR+LAviZI8W3jxgq7 3M3I89jttjgJEqeVMe9QKlF7BNiAKEAXQCjB0q9PD2e1Km74RIaA/NabcklAx/SZ0TaO PXzssFs+32COHYQ/Pfdr8H+F3MZ6WqwwSSjqff09LDJSvG2W+Nj5dDKpE9f7hxoS9mpB jdqAkbNQxeHX2q03efIedQdDQeEoCQlz3PrK+7b94IiNzYQZdA6FpLc8H0nCq7WFZgCa 8DHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6SxVTHSnnrLvJlKTojFhkcGJNrF56T1eU0cMIWJ6gbo=; b=Kh3jam17PsALePNDmZ+AnvuIFsuz+YSXWOvRgIFOOwP/komH9q5v7yGKjYkum/mNTR 83EvaWqshw7MR1lnnGPQ4CEnT4V/EQI20V0vjencJokLY8f8mYLualme+JCS/QokyQI6 HUHjSjfjzkF5ev3pqJK0v1UUfeo50cQ1GSL8r7EQisB0DMh6pbNrTi41/8QgNU88wEW+ BakaaTyX8dsVK86bX3qHI9nJWWdivtDtAXEBO7G8C0UPFtdIZvWfzx8EOYu1UbiselYm pMYO7lu70gMd0ASmOxE6mEvQKGBIdfT2EaQERqUk3GH+s3JC9dtISH7HmkdvFD6/IDyK mSJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ei+LC5Za; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h61si19166038plb.256.2019.07.08.15.37.05; Mon, 08 Jul 2019 15:37:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ei+LC5Za; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388710AbfGHPZ6 (ORCPT + 99 others); Mon, 8 Jul 2019 11:25:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:53452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388689AbfGHPZw (ORCPT ); Mon, 8 Jul 2019 11:25:52 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4554820665; Mon, 8 Jul 2019 15:25:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599551; bh=2brGLRDW17KyZ3JkwFdSlCnobgYQ8m0GLWZgEhcWYYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ei+LC5ZayvDSd7+FuH8hmMjP8OeXRzczVtO0UKRfK/mFYPghH7fenCtt6zZJCmJxv ldZOkCe8hi2RXgD7yIu7vCvZM8oNjeXAHk3SEH6v7HFI/iGvTc6ocA+EgGBr1tMTvp AbZHnk7bygQz0nne1qehvUjlGMHE2vM31H3kFMSE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Young Xiao <92siuyang@gmail.com>, Felipe Balbi , Sasha Levin Subject: [PATCH 4.14 11/56] usb: gadget: fusb300_udc: Fix memory leak of fusb300->ep[i] Date: Mon, 8 Jul 2019 17:13:03 +0200 Message-Id: <20190708150519.076240236@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150514.376317156@linuxfoundation.org> References: <20190708150514.376317156@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 62fd0e0a24abeebe2c19fce49dd5716d9b62042d ] There is no deallocation of fusb300->ep[i] elements, allocated at fusb300_probe. The patch adds deallocation of fusb300->ep array elements. Signed-off-by: Young Xiao <92siuyang@gmail.com> Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/fusb300_udc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/gadget/udc/fusb300_udc.c b/drivers/usb/gadget/udc/fusb300_udc.c index e0c1b0099265..089f39de6897 100644 --- a/drivers/usb/gadget/udc/fusb300_udc.c +++ b/drivers/usb/gadget/udc/fusb300_udc.c @@ -1345,12 +1345,15 @@ static const struct usb_gadget_ops fusb300_gadget_ops = { static int fusb300_remove(struct platform_device *pdev) { struct fusb300 *fusb300 = platform_get_drvdata(pdev); + int i; usb_del_gadget_udc(&fusb300->gadget); iounmap(fusb300->reg); free_irq(platform_get_irq(pdev, 0), fusb300); fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req); + for (i = 0; i < FUSB300_MAX_NUM_EP; i++) + kfree(fusb300->ep[i]); kfree(fusb300); return 0; @@ -1494,6 +1497,8 @@ clean_up: if (fusb300->ep0_req) fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req); + for (i = 0; i < FUSB300_MAX_NUM_EP; i++) + kfree(fusb300->ep[i]); kfree(fusb300); } if (reg) -- 2.20.1