Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2701430pxj; Mon, 31 May 2021 08:35:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrNxyNonIa87FDd/arkM5ukrWPZ3P8jsfPOrElEe/6AZShA8Y340rTaXvjnacifueMxmts X-Received: by 2002:aa7:c545:: with SMTP id s5mr12883424edr.113.1622475329528; Mon, 31 May 2021 08:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622475329; cv=none; d=google.com; s=arc-20160816; b=m6pyVdQCQH5urwd92s8jsvrvCUbsuwy5Ynb5aASX39bEPXLDyopXl9lQ8s9UCzSr// CORNRqorVRe7V1IopFDiJK1L3rD4Mz7/JCNgssWnS95l9BfHq8wLHW3n1nL4Yz2mq7tO 9XFVKNiguF9LXhSofYOyhYAyYa+UdJlMt7fmVarmEnKm7VbaQAxdLu0nwaamlwkp0Ud+ 0Jxs9lhrTUXkbgtHy72FnOHLA9KFNBZ+thJB0mZzthP1NPydr96LSnkHYIshWKBT3989 kdNTKykRtw6zpwRNwPmATdXZ9oloX/lfa0q0xzMjcoHeOnr9bouRVAO8ZaowemfiHIwK WILg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ivr3ZjS2FlKygUilVXEL6+zTaLKQ+fyJZNHmkFynk7c=; b=LlTderlU/nATuEOayyP4CaBMWpcGoWSPdQuFHZB4WI7lRzDkwVLdofHifxdjsVzoOA Cvn9H2Rgdg072Ac2GI/JDlvqlWsqOhaSDhv78gLIVrpFQcE7BX0duqpHfmuNpW22cucd s4APZh6QFSSJlAJv++UjOtUmtB6ZuDUWJR8q5at/dK7pYsJkUwU35fWmAxHNPTc/3bg7 HOet9UES/ps9bFMaQqAPJsu+UF8ktBKa5UgvNldmY/rkwZQhJNcAWOT6565NbPIO5Hjh i/yLqsvM5AMHpTEuLf4wJpPCRDFCuwpuIh8HILnLDTdkOd8im4iuX2hVj3YABFmPkzgd HCfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WUJj0hsB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si15138698ejb.702.2021.05.31.08.35.05; Mon, 31 May 2021 08:35:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WUJj0hsB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233215AbhEaPea (ORCPT + 99 others); Mon, 31 May 2021 11:34:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:43306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233086AbhEaORk (ORCPT ); Mon, 31 May 2021 10:17:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B7E8561416; Mon, 31 May 2021 13:43:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468624; bh=VwB1v0Ir/EDDvDAd/knyzwsehag3a40nMAVmm/IYTJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WUJj0hsB9WlEaOPq6eMwTFp9UomlxYoXdQV0jnimliswd1nfXkmOFaYwdOZfUf0F4 ZH4Gy2AWcKeZR+y3Ws2iGjb9uC1cxV0YOqF9OYtOB70EBi+ftF9pp+CbW/lH22q2Ej ea7w+AlPok5ZWa0TIa//UbSa8H3shQXqV47pCKwA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.vger.org, Pavel Skripkin , "David S. Miller" , syzbot+b558506ba8165425fee2@syzkaller.appspotmail.com Subject: [PATCH 5.4 063/177] net: usb: fix memory leak in smsc75xx_bind Date: Mon, 31 May 2021 15:13:40 +0200 Message-Id: <20210531130650.078858716@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Skripkin commit 46a8b29c6306d8bbfd92b614ef65a47c900d8e70 upstream. Syzbot reported memory leak in smsc75xx_bind(). The problem was is non-freed memory in case of errors after memory allocation. backtrace: [] kmalloc include/linux/slab.h:556 [inline] [] kzalloc include/linux/slab.h:686 [inline] [] smsc75xx_bind+0x7a/0x334 drivers/net/usb/smsc75xx.c:1460 [] usbnet_probe+0x3b6/0xc30 drivers/net/usb/usbnet.c:1728 Fixes: d0cad871703b ("smsc75xx: SMSC LAN75xx USB gigabit ethernet adapter driver") Cc: stable@kernel.vger.org Reported-and-tested-by: syzbot+b558506ba8165425fee2@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/usb/smsc75xx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/net/usb/smsc75xx.c +++ b/drivers/net/usb/smsc75xx.c @@ -1482,7 +1482,7 @@ static int smsc75xx_bind(struct usbnet * ret = smsc75xx_wait_ready(dev, 0); if (ret < 0) { netdev_warn(dev->net, "device not ready in smsc75xx_bind\n"); - return ret; + goto err; } smsc75xx_init_mac_address(dev); @@ -1491,7 +1491,7 @@ static int smsc75xx_bind(struct usbnet * ret = smsc75xx_reset(dev); if (ret < 0) { netdev_warn(dev->net, "smsc75xx_reset error %d\n", ret); - return ret; + goto err; } dev->net->netdev_ops = &smsc75xx_netdev_ops; @@ -1501,6 +1501,10 @@ static int smsc75xx_bind(struct usbnet * dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; dev->net->max_mtu = MAX_SINGLE_PACKET_SIZE; return 0; + +err: + kfree(pdata); + return ret; } static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf)