Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1595019pxb; Mon, 12 Apr 2021 01:47:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvOyTgMD0xujzcUd5Pe2WUPTGDVFeWTqrCWixBdNxdkHyUqLybKOhK+eDmUPmK7IBpYDeo X-Received: by 2002:a62:6448:0:b029:249:d85a:31bd with SMTP id y69-20020a6264480000b0290249d85a31bdmr8982938pfb.16.1618217257511; Mon, 12 Apr 2021 01:47:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618217257; cv=none; d=google.com; s=arc-20160816; b=qdnWpJmUWKI27JOz9TOzhOFYQ4PzUZR+aUBJ5qfFNjAYQMrWenuE+masyOUBhEIPka Fxn70ZQ14FuH7zOSoF5hJGKkbQ6EqjKoxOoGoD5LxV+Puy55dsv+E6saJTdUMZLyb1eT jZquLWZ83TLEGt8DSTQ2ITbgFz4phmOy8IL7U59OoaD1Zc7YSo3gR0xGV1lm53d/V/Wj Z80u6WB2Tm2N8daTDREs9kbuGcrAlgn2ZFKpcQ2+RWX5Q05DjKYXtPSRr7R58CYtysDM LBYRvJEAKwsmuBYqOzN1tji33bQ//+ucbIJWozdFblyJiejU2rLBLbkEKfj7WA8KM5Od 2y0A== 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=d+cJreHtE7MCrBYoWntiXbeTKrWzJtwuGopjYsYscE4=; b=kH9QAlZL2OcLFqXbB8y5ClzA8K663u/a+dsMkQgQK4/sLNqzx1TLeamtJkcd9pxHQy rbo/eewPor7UlsR/cWcODy1dQrwAsqco2DRFhJjkbZGzj9k5xi8FL2aVoITG0xh96fJ1 p45w7c/sFBXPAUMsQEKtHHA7s3HvxYCTj+jBRUA4vfGbih/HhPphvSG+kym5SppMtiD2 JeuO6v7tebdT/p6lBclQ8URgnCJrjlFODuROfF90brk80StDWFIaV7w7Cr3+uZqRypsi tWy3QxSnxNoiV1yYdya+EC2NKpjyLEmgy4CwbqBA6BjeqSGLWsiILJSG0ykuRK9/Fq4P ivtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PVxLPQvR; 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 u24si15364825pfm.320.2021.04.12.01.47.25; Mon, 12 Apr 2021 01:47:37 -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=PVxLPQvR; 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 S237790AbhDLIpe (ORCPT + 99 others); Mon, 12 Apr 2021 04:45:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:36832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237689AbhDLIol (ORCPT ); Mon, 12 Apr 2021 04:44:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5F1D661220; Mon, 12 Apr 2021 08:44:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217063; bh=d8R7nMj6KP+mpfLiCn1fDgndFFAKueE9aOLYz4HVNDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PVxLPQvRvirds3NZIGzpP2lYJW+OsTgjtUcmjmoSeJpfo2Q4OLvbGtp6/YooXbXrt FpLL9QaIfOugVlGwt+4dP2DpqFbonf6Oq6WvYH2GPf9VlDpnyXGuOn3b4udAczshfJ RbtlNtqC1e2kUkQZifTFzrlKwc+Z3XmOW8OjZEdg= 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 4.19 56/66] drivers: net: fix memory leak in peak_usb_create_dev Date: Mon, 12 Apr 2021 10:41:02 +0200 Message-Id: <20210412083959.937343436@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412083958.129944265@linuxfoundation.org> References: <20210412083958.129944265@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 @@ -864,7 +864,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 */ @@ -876,6 +876,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);