Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2655641pxj; Mon, 31 May 2021 07:31:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+MdsO4TblzSLQQjIjRIy0S3DTyI+XEZ46rk08P99lkqgXivK9nqHV/7tkq+bHoohVzjkT X-Received: by 2002:a05:6e02:156d:: with SMTP id k13mr4116350ilu.262.1622471495394; Mon, 31 May 2021 07:31:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622471495; cv=none; d=google.com; s=arc-20160816; b=uG1bsp9yaeWkWlPrXl8byqNUveDccl8X3pMFM5Udsg3E9Ub/qovSKnpPBPYSxIr3OE Lzs4oK+QtepKfvXxAoakmdY5q8KYDjkSle3mwvR+fpZyr5IMH9InGK317Jqg6oFRxcip 1YmZxa0BWJH8ZVBV8+Em4QQvX0wuA5hES2fpvChHIaCoZBDRWSlwiEcRpEUGmr9YesJ7 AGvVPidZkP6wha8hINSJ1fmPokVuTsFxI4D3zeCAcZDeoEg+adXNVcyi/t1a3s6iwj+E EHuqQ8AJ/Dhq10vKL8YJdeK3e5ivbHiDjPs74EN5/GJJnoVnc/iBhf9WVU9hEHqKNPpl +hQw== 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=bip1wmHQE8L7VIOZaP0KGX5rek3QL5IwnEBrXslW71WX2JTrrkdH3dmEkjeG+5o757 61np+LLLz4YMiDff2Vx0XSy5xqRC/+Q+DUKruxTXUF3buibmJNthyu7oSsnCGvRP2F44 aA0eEYZ8AM5KerMD2ilP4Hk+SnN+ie0tjgtGM3LIQRewfszLagLyePQLMKPMesc5EHPx 1MVB2UROhKFLfEphxRNJQQ8mAcvsO13w7I83tda5/P0JmMZLUzis2va/uo6c7KJmc2p/ onNaz1IYpUh/aJXz2PqSUHZAyUji1qH3a9XVVwkoH5lthjNllVKOhuoRtvmAo57vMjZg EJaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fvakYmnr; 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 v5si1629266ioh.27.2021.05.31.07.31.22; Mon, 31 May 2021 07:31:35 -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=fvakYmnr; 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 S233721AbhEaOc2 (ORCPT + 99 others); Mon, 31 May 2021 10:32:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:55706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233122AbhEaNyc (ORCPT ); Mon, 31 May 2021 09:54:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 61340613F7; Mon, 31 May 2021 13:33:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468025; bh=QJ9WQDZQgeIL0suhJhnd5CI7iukTwmNkljXGip/R79E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fvakYmnrARG82LKS2sTeRauPBGuhJIwRK2AMby5dbnfYAVOHlcYah9gOrsTnCZWBu TIkIeN2yXRLyrHQvYwpKiU377M0xarPTKTCeObOn6fKVum7pOnKlepXvrY7J0VZcmS 1U6zOxrNWmvCOpZSURYkS32669kcFZ0kdYU4/64o= 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.10 089/252] net: usb: fix memory leak in smsc75xx_bind Date: Mon, 31 May 2021 15:12:34 +0200 Message-Id: <20210531130700.997727171@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@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)