Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp250212ybd; Tue, 25 Jun 2019 20:44:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxAW76jpXEgZpqgWd9IfFC5J4nhYFudGfobmXVxV53h1QUT6Rvu8Jq/Vin8PrsPEKA9KP7J X-Received: by 2002:a63:292:: with SMTP id 140mr601665pgc.88.1561520675699; Tue, 25 Jun 2019 20:44:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561520675; cv=none; d=google.com; s=arc-20160816; b=q98AuVlNOTrc12nHv9F8RH8bf2X4X98FyupTpNrQGn1F9siJWRpqS/xeEG+GsZSYz9 94SF98aGGAmmaGkD7FgfRjATDKkajlx8035FDBUI1vIkP0uCZd6TlCfGED0R/iYgHJV8 Wfgg0xBx2/ME0cWMtMAeiJDn5ZkwPqXylxKGPOYuBxP/7aTv1CiPKBwFPsxKs98+BekO Ni2/InkeXyWmlfA4OjK8SUY3GrO5x2OGZDrEZAaijnppMXn8/g9iJizcUXjfHexiStdY wos56kUhJM9M588kPBI7pqWwOzMArWFBe6vfHaHlaaEkmgl+/iW+JNo1snFlXqvivjHQ YktQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UjWcaXHA1R+7he8YXPUi9rCbsQSYPLIpJa8BMdguSCw=; b=Qw92piG+f+hcNE+sj5tgcahdz6DqVRZyTE/sC1/7an1LH4QFKD93nU8GhfMIsgQ0Fp lcOXRkExy9hUA2h8scvVXvwwpsBoNqDDJmrNJkTdHNHY6UqiQLd7PcNv/aE3RTreie/N 4IOF7Gz9lk9NU2n/JjGLWBfvBvgVjkS/tOQ0G2ALGR6Se2R0NTj/66ZxoPe6BwKyeto6 Uws2DbtFWYGjIbLQrZWccNjK6TGJTijbfMrb6+plkYKjhh0KY3EYaMBzjjxxFYkuzLXD nQlhN5gWtjzF/dSuC6BXhGu0Jn76tYtAGwKQz9J0MeG2RgSgGA5WdNy/ZMkaeVkZyv7A xaZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AL00VmcN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w1si2027072plq.125.2019.06.25.20.44.19; Tue, 25 Jun 2019 20:44:35 -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=AL00VmcN; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727090AbfFZDm2 (ORCPT + 99 others); Tue, 25 Jun 2019 23:42:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:53308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727071AbfFZDmZ (ORCPT ); Tue, 25 Jun 2019 23:42:25 -0400 Received: from sasha-vm.mshome.net (mobile-107-77-172-74.mobile.att.net [107.77.172.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E042F205ED; Wed, 26 Jun 2019 03:42:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561520544; bh=WAtDkC3Sn0v7Nf68myXvlN9U3b+YFysUdkAh2NVep5k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AL00VmcNKfQxEbprmSBTAYlSfSInGKZt8a0K5mQLQ4DlpsOgsFS7xtB1KWgY4UCUe eqtvZ7xKMTsZOu7S/GYX/H0a8/b9OElqlFLdz9Vim8g3k8pwqSRFV+bmlPtMdY57YZ FSZJIlYIo9gRLRsDzABRgWnOqSbzotrghNq8ojAg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Young Xiao <92siuyang@gmail.com>, Felipe Balbi , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 5.1 24/51] usb: gadget: fusb300_udc: Fix memory leak of fusb300->ep[i] Date: Tue, 25 Jun 2019 23:40:40 -0400 Message-Id: <20190626034117.23247-24-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190626034117.23247-1-sashal@kernel.org> References: <20190626034117.23247-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Young Xiao <92siuyang@gmail.com> [ 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 263804d154a7..00e3f66836a9 100644 --- a/drivers/usb/gadget/udc/fusb300_udc.c +++ b/drivers/usb/gadget/udc/fusb300_udc.c @@ -1342,12 +1342,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; @@ -1491,6 +1494,8 @@ static int fusb300_probe(struct platform_device *pdev) 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