Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2692131ybl; Thu, 29 Aug 2019 11:32:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwUk5x1mnBQ4To5p+kwxu8kV9/+CtwfMVgp3Oh9eIgZB1JEXXEZe2RYNKJ5pSTnM58qOT8U X-Received: by 2002:a62:2c94:: with SMTP id s142mr13183373pfs.45.1567103566650; Thu, 29 Aug 2019 11:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567103566; cv=none; d=google.com; s=arc-20160816; b=Bk76BG6cliZ+sSEkug0ic6tBNcfkpPv3goDWZ4PK32lkjEcWwhGXVwn8cXTVsO24CR X2owVip4FxJ1dPOSN/j2bold7ykInwzvgcF1Wfr2eNp6Bjmm/hp8KeK77j/dEDqmy1Na gMFBz2devKEluxrQEHGpBrkeRdcHY1DqAXb1AxJKqAl/CSLINFx6NRJFtc56z11Fnlai +VokHqlSalnIjsjA9ILHHEdC1ZTcwF76pO0JY0OzipZL4uvMLGeDEmRcOIKUUY45KhVu AHwGLvEtoJmSx5CtIUNcchngKLbDwcaK9RlYHG7RZrMzFPcU93+HGH3DkF1jyAGAxaRd NVgw== 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=/IrbI3flo7Ya3FaOPVUPg8posARMj4rggNQgqTTtZBU=; b=ZNfJw9Jcgnp2oHmOUMrGoKtVZl30QnH0D8Oc8CySjYTJjU/HB0lYdLojfjAuf7ZS9b eUFwoug0LZmk/eyZ6U3/2xRF2tpYJyZCV3FxA2JKDdf4l94PHVbJIOolx7DYWmTvVAoE Hl5TZy1qhBDINXnlBHkuHGzHpL8H4qTb5BoYeEYNdrN68qg+P21WKRT0bzmz5U2kt+eB F71wAkzkwXdXuUfSzvpKnz9mvhlYy5b13b+GGNjX9tTCLYyajrxKaBvmOyJ94hSIis7n WbOYBgIKFU7m/hGl8qQeqnalYyxqRMbk/AqMtxlg6g9dK8Kn39+sJcomEvq3p72KUue/ /31w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WoUOBfx2; 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 a8si2718286plp.406.2019.08.29.11.32.31; Thu, 29 Aug 2019 11:32:46 -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=WoUOBfx2; 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 S1728975AbfH2SOq (ORCPT + 99 others); Thu, 29 Aug 2019 14:14:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:56290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728949AbfH2SOk (ORCPT ); Thu, 29 Aug 2019 14:14:40 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (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 C4F8E2339E; Thu, 29 Aug 2019 18:14:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567102479; bh=baCRx9JVUqRa9cCGCXJT1DbEF8aU4ZfGASvfIub9WjI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WoUOBfx2QKCTHcSfolNg+8xu2tWLk5CKoi4vDznXY2bihR/kJHfXjE60vPWEd2wtP EMLA6qs4RSaYCmDx+whhdngvc+e2cPkgtm3nAyf/zoxeTUgAcVvxeM+r7/FtjVqdT6 YtltlZJ5vZWYQWUkZzODvsw2BBnNg6yNjg3jLMzA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Wenwen Wang , "David S . Miller" , Sasha Levin , linux-usb@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 41/76] cx82310_eth: fix a memory leak bug Date: Thu, 29 Aug 2019 14:12:36 -0400 Message-Id: <20190829181311.7562-41-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190829181311.7562-1-sashal@kernel.org> References: <20190829181311.7562-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: Wenwen Wang [ Upstream commit 1eca92eef18719027d394bf1a2d276f43e7cf886 ] In cx82310_bind(), 'dev->partial_data' is allocated through kmalloc(). Then, the execution waits for the firmware to become ready. If the firmware is not ready in time, the execution is terminated. However, the allocated 'dev->partial_data' is not deallocated on this path, leading to a memory leak bug. To fix this issue, free 'dev->partial_data' before returning the error. Signed-off-by: Wenwen Wang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/cx82310_eth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/usb/cx82310_eth.c b/drivers/net/usb/cx82310_eth.c index 5519248a791eb..32b08b18e1208 100644 --- a/drivers/net/usb/cx82310_eth.c +++ b/drivers/net/usb/cx82310_eth.c @@ -163,7 +163,8 @@ static int cx82310_bind(struct usbnet *dev, struct usb_interface *intf) } if (!timeout) { dev_err(&udev->dev, "firmware not ready in time\n"); - return -ETIMEDOUT; + ret = -ETIMEDOUT; + goto err; } /* enable ethernet mode (?) */ -- 2.20.1