Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2064591pxb; Mon, 12 Apr 2021 13:23:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWBoOD70EW/zdhWYa9zDPeUdY2pgTo8gT/9f913CrcvSRneUDPMy/OO+Hee5ATxszR2EL5 X-Received: by 2002:a63:4c55:: with SMTP id m21mr29580718pgl.251.1618259003822; Mon, 12 Apr 2021 13:23:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618259003; cv=none; d=google.com; s=arc-20160816; b=qzF2QrKJZYx+VHHk8Kc4of2+nBcUJaJBO5z0z3ynkKFGN7KtUqFcx5SZX3dHNZzglh 3cd628DDlhqNyTpoRFsxWiN62gO93Zz4jlxalI+TXCK/E2cXMhhqff/u5gPhpEPJQiMG vVPR2eh+hVh4eH9tdWRZovL2LVi3h9767J+H0X24cpDvrDo6MtvE8whaIkJMR5Cd/hh8 euBd0+GnIwGT5kf0EvT5NgLcm1u/Ozimtq12LfAp/hXYSzBs0CIWoJUZq33kOVsuTMFI VI9ngo6zSnpjhPXCjr212Ta4nGByVhkmw2qgd2O0Hrza4NJIfw0PkDKT3LFvh+DwpjfY oVBw== 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=b5nzKHJFBptJ5k9WRA4a+Ub+C6354XvB/8mKmsNe8po=; b=pweKzT0K95nMVDWtxAEBCbKG8RZD44/2sUCEZkXMtdZyoG6azAVrqBr2mptVTFXEgk XDigyC7LXzk26ncpWQZOiAekK1xGRad41yoYNwRudGNF7j9S4v31XGFbQ1NP997APQk5 x50bMUEk9ysdc2YniAt1G4lJvFnGc1dbKORI3muNm0+Ujqnjv685cgk/5lljEphE8HtW uXQSik1WnaDVYbdpoLK253cNBS6HauzJ5v9co9yidWk1zSRCjpR/tHTtnQA4+jDaNfcQ A3zUATmHsSLVKD233ZhRNvw2mU1tSQD2PrPVloVrHUzeMy5dkJxntT4Y+IQBlZNFVaow xz6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=u77Ik5qC; 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 r25si15591970pgv.151.2021.04.12.13.23.11; Mon, 12 Apr 2021 13:23:23 -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=u77Ik5qC; 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 S238784AbhDLI5W (ORCPT + 99 others); Mon, 12 Apr 2021 04:57:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:42836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238518AbhDLIuA (ORCPT ); Mon, 12 Apr 2021 04:50:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 389C861285; Mon, 12 Apr 2021 08:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217368; bh=f4cf2W2PIxiKg3K9+VuAw4I8l9vPQrbb3gOI9m+U5uw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u77Ik5qCGxP6wPJBtorTTBYV4c+XUILfrB3oRLiMeaajCchi+D8PMcUDWEhDrnQ2x 6jSQ75NkcXqlSvxiRFYXsR+7ZUCrY258rnc/xRiBHXeLa7Oa03O9kG5uBn74shExdH YbM857hw6Y9u7giGqVQ+3nM4LsOOMmkU1TwkZRyY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+91adee8d9ebb9193d22d@syzkaller.appspotmail.com, Pavel Skripkin , "David S. Miller" Subject: [PATCH 5.4 101/111] drivers: net: fix memory leak in peak_usb_create_dev Date: Mon, 12 Apr 2021 10:41:19 +0200 Message-Id: <20210412084007.619270481@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084004.200986670@linuxfoundation.org> References: <20210412084004.200986670@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 a0b96b4a62745397aee662670cfc2157bac03f55 upstream. syzbot reported memory leak in peak_usb. The problem was in case of failure after calling ->dev_init()[2] in peak_usb_create_dev()[1]. The data allocated int dev_init() wasn't freed, so simple ->dev_free() call fix this problem. backtrace: [<0000000079d6542a>] kmalloc include/linux/slab.h:552 [inline] [<0000000079d6542a>] kzalloc include/linux/slab.h:682 [inline] [<0000000079d6542a>] pcan_usb_fd_init+0x156/0x210 drivers/net/can/usb/peak_usb/pcan_usb_fd.c:868 [2] [<00000000c09f9057>] peak_usb_create_dev drivers/net/can/usb/peak_usb/pcan_usb_core.c:851 [inline] [1] [<00000000c09f9057>] peak_usb_probe+0x389/0x490 drivers/net/can/usb/peak_usb/pcan_usb_core.c:949 Reported-by: syzbot+91adee8d9ebb9193d22d@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/usb/peak_usb/pcan_usb_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c @@ -856,7 +856,7 @@ static int peak_usb_create_dev(const str if (dev->adapter->dev_set_bus) { err = dev->adapter->dev_set_bus(dev, 0); if (err) - goto lbl_unregister_candev; + goto adap_dev_free; } /* get device number early */ @@ -868,6 +868,10 @@ static int peak_usb_create_dev(const str return 0; +adap_dev_free: + if (dev->adapter->dev_free) + dev->adapter->dev_free(dev); + lbl_unregister_candev: unregister_candev(netdev);