Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4484710ybe; Mon, 9 Sep 2019 09:55:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkhsAIU6UtE/oZ93Xh3LhmWjQokWUQOZ5P7r2pcVpyfTqn+DYClRr9gYb/LpP+X2O5VmJX X-Received: by 2002:a17:906:3187:: with SMTP id 7mr19856431ejy.238.1568048140377; Mon, 09 Sep 2019 09:55:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568048140; cv=none; d=google.com; s=arc-20160816; b=X7eR6+DjKBXz1dEH4EGC38OC5H4GqLhaeUkmntLZ5iovB0C3jDKOQ7vDqZQ6Eq6ZyA jVCv+RbjAb9toyXOinmZOJ0zk2L34eiveORNMf2zkYPqAwsSh53srlUGz8NIq1jA1j9B Px7BmSFZwIOyWIQO5DfDtpx2ULasJdHvaKfSE+n0RHLHakZ4c09n+n+qzFfrLZ+R6iaW xQKFpPTwjWy5+ZNj8wmCeFD2CGRubrOD7rTicLm00rAnmcdMypXIpcvZnG/D3qj+sTjQ gafOjkTDhmAD9Nw2I/j5WqciouPXpXwfEvX6jPPrG82uQE+1MYZg8tkc5o3xD8HUleql g2Ng== 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=vxKW0Gs5rkVNcGPJZ8/imTRYwW11tzlRGXpM7ekfMfA=; b=OyeQNKmfIOgfEFlwsz2+cHJ11tIUywTPo0DG0jclO7zwXv+wrjx1haHy9IOY16eesx c4VQLOYcGGX343CstFaWU1AtRMCOa0wiLIwQ7K8P/aGNRuKKwhRwBcXYVC2i0GqOZa31 ZAp3xnHGKDk27VDMPSR9XdQ7bJ3tanLyOJ6hhdSzWwhdp9Js9GCXmooq8m/adWTciRur te935/NB+NUS5bhbcSdKVsxpG0tds53z2GikCHTLFCvGM0nmWCw5s5bgcZnO+rXP44e4 DMOQuU/4RvhTiyxyIUE8sMrf8bcRMY08M6/kF0gm0oakaesme50BdEXN8sMvkNVBdpsm Ek/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RIjOlm28; 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 c54si8700429edb.230.2019.09.09.09.55.16; Mon, 09 Sep 2019 09:55:40 -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=RIjOlm28; 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 S1726883AbfIHM77 (ORCPT + 99 others); Sun, 8 Sep 2019 08:59:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:60572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730062AbfIHMpT (ORCPT ); Sun, 8 Sep 2019 08:45:19 -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 DEEA02081B; Sun, 8 Sep 2019 12:45:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567946719; bh=VKIhn3t5HKFT55uxxSW0rh1RrHK5MQdyDgOmvlyntj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RIjOlm28n9bAd9uETz6fM4dbXsKJ+p6YfpAZI/2x8jGAPMVGSEcPuVRNGT/5S2Yop si5rJSbG1H2RHE5ybGqrhvcbI9NaDhhGNWYa08vnagM64cewVDA2jG376cBtIBNwR0 +yob3CnuKKYPhFHjJfYz/AI/VvB4bTkEGWaSwwXk= 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 4.14 15/40] cx82310_eth: fix a memory leak bug Date: Sun, 8 Sep 2019 13:41:48 +0100 Message-Id: <20190908121121.763191475@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121114.260662089@linuxfoundation.org> References: <20190908121114.260662089@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 947bea81d9241..dfbdea22fbad9 100644 --- a/drivers/net/usb/cx82310_eth.c +++ b/drivers/net/usb/cx82310_eth.c @@ -175,7 +175,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