Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4431686ybe; Mon, 9 Sep 2019 09:10:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxc4068eaToWhrFf0gPDdRGcdlMkrHiZ6mSGrvmf4TOk5v+69G3FH+XZL07GFyZUM8i80JM X-Received: by 2002:a17:906:7ac6:: with SMTP id k6mr15894682ejo.243.1568045454513; Mon, 09 Sep 2019 09:10:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568045454; cv=none; d=google.com; s=arc-20160816; b=08iPTKGayvAdIXYsn1DCDoGNC1OE3cFzkzBcu09X530nsOPnwk280SlYXTg4MdxNKp BVYzWixfcx/+aU7GuHm2Z3PcBKFc/VOBLIKviD5OAKsAPw/EjVBJIyRYb98X9eBm9ALC 0WUBNARrgUyOWcL2T7fqAp85R8b+MvutvopbfxgXBgnXAxqSql+qRjhCsH1KdVKek0x1 ViH5Gp3KGUMfdcOjpvBFO96qDSLHaRCsMGkY0A4vlHdhryL7nd8RU90LeKaYe7zpCfrk CflBboImBosrgWZUIfiNJHcAd7k2o7mPDGg5EqMXa1nVIFAAGr5F+sQRastStS+XWpd3 aVuA== 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=4sh6P2pbywQqWZUo8M/2oKoAQ7jxkkKv2rz3vQmbDxk=; b=F+dLArc1aXfkaI+5ZHzC0SBIEVfJVyxTFfinQlgqWsnvB9zqcfv5WCKhIq9bcOolhZ f8uCHg/H9eIRmOLy2AaeeAiJHAkofm14YuR+pSiJ/dIALQDEfRpWzptKx0fHRfs7Ir1G 18EhovbXRc+5v9BtImx7062P25XGv93hFgu8XgsSH5lH/OG6wpceAuhM19/u9FCfiLgE 0g0GX47e8GEYGE19fmTOytGLhWA0ZsIAqV7Nx+AXK/Ec+MReSOONVtjFoGpyQgLf7aMG O/tyDFTc0vqe35xSnkkrBOqjtFZnoLMhrmJ2/X/0Xivb72AzBBGXEbQbTezcrcQ57ddr Oa3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=c+Q1Cvjb; 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 p8si7722661ejj.119.2019.09.09.09.10.30; Mon, 09 Sep 2019 09:10:54 -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=c+Q1Cvjb; 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 S1726705AbfIHM5w (ORCPT + 99 others); Sun, 8 Sep 2019 08:57:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:36540 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726295AbfIHMrv (ORCPT ); Sun, 8 Sep 2019 08:47:51 -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 59202218AC; Sun, 8 Sep 2019 12:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567946870; bh=2qd5XuxST3w2t01MawjYozqJlGP8gqw1nAIGoR8AAVs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c+Q1Cvjbo6E+IIkYC97NWIKOEC9M71NaH4f1FnQZFimufIBeYS3G7/vcBKMJdaCMo Q2fFpyHJFcMc6X99cikvTrRCdDUGhJz7UsyKya8ii9lY1RFd4ijyxNpm0KYe8tExoB da+ZTFfaZaq1AeYmgauVeuDZXXyPpuAoSPZ91FKs= 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.19 30/57] lan78xx: Fix memory leaks Date: Sun, 8 Sep 2019 13:41:54 +0100 Message-Id: <20190908121137.305197779@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190908121125.608195329@linuxfoundation.org> References: <20190908121125.608195329@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 b9cbf8a64865b50fd0f4a3915fa00ac7365cdf8f ] In lan78xx_probe(), a new urb is allocated through usb_alloc_urb() and saved to 'dev->urb_intr'. However, in the following execution, if an error occurs, 'dev->urb_intr' is not deallocated, leading to memory leaks. To fix this issue, invoke usb_free_urb() to free the allocated urb before returning from the function. Signed-off-by: Wenwen Wang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/lan78xx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index 8d140495da79d..e20266bd209e2 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3799,7 +3799,7 @@ static int lan78xx_probe(struct usb_interface *intf, ret = register_netdev(netdev); if (ret != 0) { netif_err(dev, probe, netdev, "couldn't register the device\n"); - goto out3; + goto out4; } usb_set_intfdata(intf, dev); @@ -3814,12 +3814,14 @@ static int lan78xx_probe(struct usb_interface *intf, ret = lan78xx_phy_init(dev); if (ret < 0) - goto out4; + goto out5; return 0; -out4: +out5: unregister_netdev(netdev); +out4: + usb_free_urb(dev->urb_intr); out3: lan78xx_unbind(dev, intf); out2: -- 2.20.1