Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2731867pxj; Mon, 31 May 2021 09:19:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywMiaBTotxrpx/aMAVuaL+a7RVAQHSI+6zAZWbxu9zTq6Si+gg0w26G7M1PQKN0lo4hRmC X-Received: by 2002:a5d:9343:: with SMTP id i3mr17848108ioo.77.1622477968322; Mon, 31 May 2021 09:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622477968; cv=none; d=google.com; s=arc-20160816; b=E/fgpaKMlxhtX4z59AscQUzw6KVJfZxo79BhweOngHlFUYCzLdgH0uB4ajgPx2RXCW msohpBnPEVabwNw6HNKBwFroLFSIv0RwQ2bjAr9kHV5oCBbz5cwIQS8Sv5VmfH9fw2sL QN5fkS85shGka9G8rp/OgNAvr2zwpRtsZ6D3KbCMQrqm2SObQqzuHAS+sFIGHFY+lj1F jAljNKjTemruJR+iTXpnO/zrjC4VIkct96YVUHOfVpt9NHg8FhrAtiACS0TXn1MxH/s7 Ylb3UZuX1QyToEXecNpT1nD7CGH+4s94VCN7U0tWhbCgXrpcdssYUNyQNNQV0W2kVxuY uh2g== 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=8egjufZVmG7a6rexLZVr2T3bgoS5oJwhFxUQphLk3Bw=; b=fn/4VekNYWx0cwEf+Yof10LaIlg83UMBohl4ygyXZwuac+xEUfuJghHdGdDMyrujX6 Xff1jSusZ+2lzMdutiFC/3Kss7x6DJQhQXiSaTqGOfsBYpVZGPIqFQJp/mAyTuVG1mx0 T6MCBKE8QUvVpckwFqL7u6fThjPlxtLvTly5AHNx85Hl7ig85j9VxZ5PwzBpoXCK6eTv 5tXT++yp/iLt0dzYFgrsbnK/yswqHqrTSrHtjF9dO+OP/jfvIdQFTYlpTLWj1jH8GFHO +MMb+i/UwlphSEfwmP4TXDqckzGkQldiEkJzH7Cg+iqZnoJCL92YpgWgaY+v1j6+a6iZ gNnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GBxHfARE; 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 l12si7375589ils.9.2021.05.31.09.19.12; Mon, 31 May 2021 09:19:28 -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=GBxHfARE; 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 S234806AbhEaQT5 (ORCPT + 99 others); Mon, 31 May 2021 12:19:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:37972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233599AbhEaOlb (ORCPT ); Mon, 31 May 2021 10:41:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E577F61C6A; Mon, 31 May 2021 13:53:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469206; bh=QJ9WQDZQgeIL0suhJhnd5CI7iukTwmNkljXGip/R79E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GBxHfAREk60kHLCcr+vadgsd3y4HwMR3Wa57rFPVkTu90GcXB1UzBP/XoKX+eXx60 sROW37Q4Yo5OiDG+mKghhixyabsWdVvOKsmDiWZH3TQNyq7eT8/gXiwYT1LcbH+Qal DVGD8mbJdtKHPLLoElM/D6VVDLkxiLG3hpVNqvp0= 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.12 110/296] net: usb: fix memory leak in smsc75xx_bind Date: Mon, 31 May 2021 15:12:45 +0200 Message-Id: <20210531130707.635279241@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@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 @@ -1483,7 +1483,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); @@ -1492,7 +1492,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; @@ -1502,6 +1502,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)