Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4427448ybe; Mon, 9 Sep 2019 09:07:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqO0J7l4j2racItRjH/czN7FjeEpBuKlLC2rTZk2TitmAEnw99cy8AstCEASCZghZcrDOT X-Received: by 2002:a17:906:3545:: with SMTP id s5mr19584298eja.73.1568045263152; Mon, 09 Sep 2019 09:07:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568045263; cv=none; d=google.com; s=arc-20160816; b=jbJjv/HvP/ELzTGmi1//hEOObsrN5+vUqRtpeffSATPW/u3hqr4xxUFwNSaE1nv58H Z/E6KlVhqMWDsTE11SDDh1sh3zZeDvnTCDrHCH/RzbFh5Hsbc8O7bntgvFGVmW+OZWLk eFsUIj/t88Unpsy+QnuUqhdBk7agG79ZwcShtxHDx+CLkDV+sQiluUtj4dcz1zhdBZee YATUvqxmWk9qjidWvF3NxyPEdRolDGJbd3xP+rAL97yggkPCstZ4U8wABIilz3mGwG8V 1fSKE4qNQ+IEyWmPPJNiD6NEkHEvBHMx/irW/RTTTkPg7bqzQVP6WhZNAoUgkIVBiOG4 LS3A== 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=HKRgZ2IH0huwIXgyI/q1W3q0oPEvLv3byNwaNq/R9M4=; b=r5/JcNGNpRLyGDjWOJTQ+CiOeV/+DOPrfhuYWXujEMnHjjH0kMk6FlbIpsKX27UvqJ lVpF/NzRZehRh/AXus0V64CfRVPSC6MM8naWQz2yLuL9ZS1wYTbc/rC0Fu/XXHzdyyMh FPjDbUDue8DnoiIXJsDiPiXRcJnjhL66r2/B0U/DarojpkjZs7xGadijaoLMGrOtLyAv VY9LADX/VA7bXLmxQeB9m4vaQspu7fsfjSH9PAoILrJansZPgGqoXARwc7kK4UjTyAgH Bzor7g1fBk/eC2bjlRHfx2d3l+aIS9OCSgPc5rk+FfqVdUlx7m3Bcv79dPzuFy6IaoFD EWOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I5N+UIv8; 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 c60si7292108edd.327.2019.09.09.09.07.19; Mon, 09 Sep 2019 09:07:43 -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=I5N+UIv8; 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 S2387563AbfIHMxT (ORCPT + 99 others); Sun, 8 Sep 2019 08:53:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:46160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387546AbfIHMxQ (ORCPT ); Sun, 8 Sep 2019 08:53:16 -0400 Received: from localhost (unknown [62.28.240.114]) (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 AA6BC21479; Sun, 8 Sep 2019 12:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567947196; bh=oJTbKzxJkcEwZQlCxpeyvfC1qpG9Tz2Sjk5W6hTvbxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I5N+UIv8YmvRQe6bitKlrRnUJi6UI9Rmmt4HXIuYcDK4Us6MEX5LvwWDnru6rngQ4 1kZDr6dFArGyVXZvCciGUVzfoP0B67tS7ZIqZzQ4ga+l7IYSj2VDUSrU+gEvgISyU/ hNFpWze28OML4vguQDWN5sDLJ7bMtaHJx0rjVvlU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wenwen Wang , "David S. Miller" , Sasha Levin Subject: [PATCH 5.2 57/94] cx82310_eth: fix a memory leak bug Date: Sun, 8 Sep 2019 13:41:53 +0100 Message-Id: <20190908121152.067123010@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121150.420989666@linuxfoundation.org> References: <20190908121150.420989666@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 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