Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2652643pxa; Mon, 17 Aug 2020 15:34:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1i1oBIO9PSLWnd2GCpZhoZ4MpOpm6s/fFaZQn82vOzaOuqrZiMsGN9VwcLQbVAS8sjqvB X-Received: by 2002:a50:fb10:: with SMTP id d16mr17273314edq.134.1597703692670; Mon, 17 Aug 2020 15:34:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597703692; cv=none; d=google.com; s=arc-20160816; b=a3H6VmuJD+/KSr3qarE2LZ056Aue1CrXyMu+vkdRLJ/eeTJOyD0WNLYBvFahLKk4C/ VAmhXV4it39rGFybqsb3DnlRFe9UvH8wedNgDmA+d2QNbB4M3sXmLksy5HpMmkngbdWa dV0xTf/34kchjhHqCvEjy4jD+tCVNiptII4zrX67ykI3OVkS5nEXIHcOVr926TOGzBAw F4Dpz6xH1SYY9DaF/G4TH4VvjhbOB55E35QKtkJyJyur7aDnAdOwqRvgquNivb4mfBVH rHht5QnyHRuOMjDoXl6o3ubvF3uHFsHUTmq/gI61hbOAmg4zi7PR7cy+F0QDXohaO0HQ ehqQ== 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=W7hrMe1/cVqUAb3kPhS07HmHQRjREw+Z08sjdKhp6Xs=; b=a/+RqAeOM5TT96Z4a61AbRPJcAQq1EGx7PbUXN5xEq82lD4yL6Owb1P6dkUuECXEhw 87KpzyRqLNT0FuUKZK0GiL+jdjQU/Cv2qeEIx9joUrBkU1q6qcDpTsTwwEw+w3M5ml2Z M/JpExWW0cETQQ+Vh1MP5sDwKQwsCrISsPrMOScfZc+GPsdYbt1aGLYe0IWe0e3HXggi Xb4Au8CGdB0203VIt9dhMtmdgWtGOZE+uHX7/AjwpCBADBI/icPIGYnrW3udvdpcts6f l0LWvz407E48IguaMX9t4En7WSZU3Xi5o6170Tdzl09Rc3VmSAlLfcPToCmImqyPG2Ci jN4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LxUbLQDR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h19si11840828edq.302.2020.08.17.15.34.29; Mon, 17 Aug 2020 15:34:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LxUbLQDR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389533AbgHQROu (ORCPT + 99 others); Mon, 17 Aug 2020 13:14:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:45400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388716AbgHQQMo (ORCPT ); Mon, 17 Aug 2020 12:12:44 -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 09BDC22CE3; Mon, 17 Aug 2020 16:12:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680764; bh=9DgNbXuE12qTJhsSkDbD8Ork1WkIfuFJiXNEK4kiDKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LxUbLQDR5vbkrmxrnN5y2C8KBWK8bd7bsxgF+IduovsjsW2QQHbwsQI3IXEAM+HeS cxWNLmDDiSipmGYixC1uT7KN/l9J9Nmp1+oI9J4KUSpSUPKFMnndqd9/zXZan49gWa LMpItRFb19x5UP7vEIjuX4dSUqLrmMsptsajhNSI= 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 4.19 048/168] usb: gadget: net2280: fix memory leak on probe error handling paths Date: Mon, 17 Aug 2020 17:16:19 +0200 Message-Id: <20200817143736.153439738@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143733.692105228@linuxfoundation.org> References: <20200817143733.692105228@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 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 ee872cad52705..a87caad8d1c7e 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -3782,8 +3782,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; } -- 2.25.1