Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2672778ybl; Thu, 29 Aug 2019 11:16:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFIjs3GTUMeCTIIP83l0QNBhyjYkhsKYqCyMJqC/dpb5zLvlXePbOy97XOFvLBiy7NztGY X-Received: by 2002:a17:902:183:: with SMTP id b3mr11562388plb.210.1567102596754; Thu, 29 Aug 2019 11:16:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567102596; cv=none; d=google.com; s=arc-20160816; b=p/fH/KdUL7RIkRzxNLiR5MvxevyU2WXFwPBtvj/7AEs6CsgnjYv9QQmp1wEMry9j0T WwaEUwQj/3dWpdqpikONMfssDNaV2PTFws1Gse4hkYvSPNP6aIOMW9g8y98M6Ndy2SOH WNruc76/MlkQdmUb++1LFe4IxuWcVUf/4Mk4EYGrF9v0qBiOcR75ORGhKE8Z2Cz8nMJC Kyqxu+AzuOtLbIKbKEUtNFIm2+MG49ql5pze4ykvQMBw7LEjcnj0YpVq5DXq7yW3Qavi 2lSlRgORpozJZeHf1wLy4qYgL+eIfC99GB4I81+M2FFykUcDKShuCPZS4z34i3j4yRoB PmPA== 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=DLw4va5UkOTVpsY911/gyoRj3Kx5I4H+wv6+vG7NTg4=; b=05zlC971UfZA0/tBB8VRqFu6MXRcE/omXQi4/z7VerRzmVgcvJfoDe8DLJcuwEFw7z 2y7nhN1fv0bl3P6BsSTWAh2c/iwlhOClrihASI4tGyb3CtU6t89Y5omFcmFSbkP12tOK shQ/FYGWCUXOqDCEpeqnJkwQaIUVYo/i7yAuCZ3XdsSLs/rWg21eRmVqYdEwdACW32zd XmfId6svuYju4RN/vxxTeqD7LT2CmBtFcHY3kJVF4eVGthsae+X99ShIkrvzOqBy3+Bq Yaa1pWsBIAwBL8FRbOw37OSGlkT3beMu3xhuN4vJzTjD0KZt+US5H9QnKdJnMfB/FoxH dZJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K0hTxa0Y; 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 g10si1841588plo.203.2019.08.29.11.16.20; Thu, 29 Aug 2019 11:16:36 -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=K0hTxa0Y; 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 S1728938AbfH2SOi (ORCPT + 99 others); Thu, 29 Aug 2019 14:14:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:56222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728017AbfH2SOg (ORCPT ); Thu, 29 Aug 2019 14:14:36 -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 CF2D82339E; Thu, 29 Aug 2019 18:14:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567102475; bh=tHvS5YS1DOGqMguSYYPBSc/FLkd8zsZcv5hHnimAuus=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K0hTxa0YiKfnDK10Xz0YXCZqS9jfqFZHU5Aigzc9R+2G1ngBQuXqpHLduQSuDfiJe /P7qjvrmZ7BVQwwnhna2Sh5jDU9s4z58PK91V4loDzdNbZHKQ93WiVM4KImBnUn6Y7 ftbD6L1HkWj6Z2RR3diWipBCsWLbvLT2wtCsJH48= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Wenwen Wang , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 39/76] lan78xx: Fix memory leaks Date: Thu, 29 Aug 2019 14:12:34 -0400 Message-Id: <20190829181311.7562-39-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 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 3d92ea6fcc02b..f033fee225a11 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -3792,7 +3792,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); @@ -3807,12 +3807,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