From patchwork Mon Aug 17 15:12:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 266086 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5AE5C433DF for ; Mon, 17 Aug 2020 19:04:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B6F6C20758 for ; Mon, 17 Aug 2020 19:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597691072; bh=SNx4u4/k2IbtAP3EPJ8PZIqvxZtBKRyULR07bQ8PFZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=E6Nx51sLE+4KgSdwv7d6ahFP56cpeh5yp4MyH++5Pg58dLjO/HbkJmEdc9VNKIvba oc1Yg0cDMd3zjcKza7WiRIZXP4TccHxe6phb6t76EAlhzrCIz209ry4ipT+VoHy7Q4 4Ev4E3QKen/iUO3d11aEoDO1+JnRb8LEVN3F83g4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730811AbgHQTEa (ORCPT ); Mon, 17 Aug 2020 15:04:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:57136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730664AbgHQPpn (ORCPT ); Mon, 17 Aug 2020 11:45:43 -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 1C2F220760; Mon, 17 Aug 2020 15:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597679142; bh=SNx4u4/k2IbtAP3EPJ8PZIqvxZtBKRyULR07bQ8PFZ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RABhPhgA6Mo1e5qEoIco4k4nQ8BAmBTZJqdNwOGT8nfs2IWwWZDx3bzdeCLZv1cVg dfJbQpzfmYfJBISAmjV9GnV1uMnOK0wxs2qDUuzTtcqdt60rsmyxvkLH2sH/LjhE1Q EZrrYRprspVftixlkxQSNqylCSTshxBEhXloJg4w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Evgeny Novikov , Felipe Balbi , Sasha Levin Subject: [PATCH 5.7 110/393] usb: gadget: net2280: fix memory leak on probe error handling paths Date: Mon, 17 Aug 2020 17:12:40 +0200 Message-Id: <20200817143824.951480958@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Evgeny Novikov [ Upstream commit 2468c877da428ebfd701142c4cdfefcfb7d4c00e ] Driver does not release memory for device on error handling paths in net2280_probe() when gadget_release() is not registered yet. The patch fixes the bug like in other similar drivers. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Evgeny Novikov Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/net2280.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index 5eff85eeaa5a0..7530bd9a08c43 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -3781,8 +3781,10 @@ static int net2280_probe(struct pci_dev *pdev, const struct pci_device_id *id) return 0; done: - if (dev) + if (dev) { net2280_remove(pdev); + kfree(dev); + } return retval; }