From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 33DC6C433EF for ; Sun, 8 Sep 2019 12:44:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 01F6A218AE for ; Sun, 8 Sep 2019 12:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567946695; bh=VKIhn3t5HKFT55uxxSW0rh1RrHK5MQdyDgOmvlyntj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zkshsj3Ae2UZCqtfSKy8sOHrZd+N6BdRXWFemvdThEzJou33WRx5jhP3WucWOB9uJ BV0+6KDHntTVUelE8b59+0n8nleL7OkCtlhgOk4sxRa+OQSskfrnLsZsv+OGuJ67nR NRF+0oO/DblS2cRVuRwAyo6So0wFTxKT4CUr7Bno= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729934AbfIHMoy (ORCPT ); Sun, 8 Sep 2019 08:44:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:59822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729904AbfIHMox (ORCPT ); Sun, 8 Sep 2019 08:44:53 -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 D81462081B; Sun, 8 Sep 2019 12:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567946693; bh=VKIhn3t5HKFT55uxxSW0rh1RrHK5MQdyDgOmvlyntj8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bH4Sur2J/l6tUO5K7npIiGBlpEMeyC/Hv0Qbq2z2TA3UXS2p7PV5m2Ey25MYzn1Yx Xgd0rAjO8BzzUY/zHcYHGP0c47x0iZut1NXnp4lF1lQMNZ1HBGQUxR7YjAtdPsQGco RDSffXP/vIIgf+15AR8E5u0kzWbIO6iheJ+aSNMw= 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.9 08/26] cx82310_eth: fix a memory leak bug Date: Sun, 8 Sep 2019 13:41:47 +0100 Message-Id: <20190908121100.249977437@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121057.216802689@linuxfoundation.org> References: <20190908121057.216802689@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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