Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3523355pxf; Mon, 15 Mar 2021 11:27:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9yLWkcDyeSFAsRfdm4b+qa+9QXXcsFSraEu4YNSEyKd5m5vKOYtDED65eZeqD29vxd9YJ X-Received: by 2002:a17:906:23e9:: with SMTP id j9mr24554483ejg.78.1615832843772; Mon, 15 Mar 2021 11:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832843; cv=none; d=google.com; s=arc-20160816; b=Yl5OsdCvrw1VuT8REUsR7PasKFhnWMnxrAVwZsGrQ9DRusUlz9v40YL061DNYOnCa4 R5BHDfvRx/N/6hMbM3VbZHdFoEaTb64ObzqRsSuVWODBfU59h9tI0OeLjrFg15j2CLId GlJIG5gbJM5/PMhfdOlCn8OFnaEueKSNBMdjKkwq2IyZ+4AvyUHpaim15gQvQljmzBto 475b9Xzt7n5/UOCMTj+pRuynkKCVUrUEEbGo+uByam1iahdBxDyz9NskvMFrbszQNOZl +J5mPLGg7MIOnqPm+swbyErBqugMQr9C3eRQnUA5sK1h8hML44SN5VHX/oPcXGGegSFA sUlA== 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=IMIxVGtxBw8+dXjJ1rck435b/eudSg/7trUDuT7oj/Q=; b=CHw8MVLnaxWfv4AYAUE54mLfAhkoUx1qbT/5arMHdOnJnR/iEJ6teMhUIdQLQnK6gr v+wukQvljPiUu2pXZ7PLUjCDs1k9KuUmv0vgST89L+qskg5mfPD0kahDk2LDs/v5H+PU kN7bxbIMVUhjnVcf/MzicE+r/POiiS/CP4q3PGQWE8HpDAmLWnzTHua9H2ThDkBTdx9t UDQZ/gJ8faluVxUTU5IZAMFOAJ+Vf8Px+jErXpDvJbAPw0K0iWxul3s1LCArxSbos5KR ofqJ23+LTh/uItisfYGr+wcyqjgyp046JgYUi/+oDaClYJPznxR0cZtNOsV16SYE2Lo9 BN2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YCcEubJH; 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 a3si11380679ejd.167.2021.03.15.11.26.54; Mon, 15 Mar 2021 11:27: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=YCcEubJH; 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 S235119AbhCOO32 (ORCPT + 99 others); Mon, 15 Mar 2021 10:29:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:37500 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232984AbhCOOAa (ORCPT ); Mon, 15 Mar 2021 10:00:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C227364F0F; Mon, 15 Mar 2021 14:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816804; bh=2wt3srBQLujzsopo+9BlZr8r/Wje3pwwVlb9R6il4z4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YCcEubJHRQTQjqt/CuErkWDpLhrLW0AvmpC/Mvjzap0NZzHOr40b7nm2PvxJ789Yy F7a/cVaWawCix8XZPUWdn3wC2My3v9RENq5OckSlFa4Y/LKxuLSt2syDABNNaPzlE1 6YSFmScPhOMAegBg1PwD9A1ebT4F+puDbcfCML6Q= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+59f777bdcbdd7eea5305@syzkaller.appspotmail.com, Pavel Skripkin , Johan Hovold Subject: [PATCH 4.19 079/120] USB: serial: io_edgeport: fix memory leak in edge_startup Date: Mon, 15 Mar 2021 14:57:10 +0100 Message-Id: <20210315135722.554240725@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135720.002213995@linuxfoundation.org> References: <20210315135720.002213995@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: Greg Kroah-Hartman From: Pavel Skripkin commit cfdc67acc785e01a8719eeb7012709d245564701 upstream. sysbot found memory leak in edge_startup(). The problem was that when an error was received from the usb_submit_urb(), nothing was cleaned up. Reported-by: syzbot+59f777bdcbdd7eea5305@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin Fixes: 6e8cf7751f9f ("USB: add EPIC support to the io_edgeport driver") Cc: stable@vger.kernel.org # 2.6.21: c5c0c55598ce Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/io_edgeport.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -3021,26 +3021,32 @@ static int edge_startup(struct usb_seria response = -ENODEV; } - usb_free_urb(edge_serial->interrupt_read_urb); - kfree(edge_serial->interrupt_in_buffer); - - usb_free_urb(edge_serial->read_urb); - kfree(edge_serial->bulk_in_buffer); - - kfree(edge_serial); - - return response; + goto error; } /* start interrupt read for this edgeport this interrupt will * continue as long as the edgeport is connected */ response = usb_submit_urb(edge_serial->interrupt_read_urb, GFP_KERNEL); - if (response) + if (response) { dev_err(ddev, "%s - Error %d submitting control urb\n", __func__, response); + + goto error; + } } return response; + +error: + usb_free_urb(edge_serial->interrupt_read_urb); + kfree(edge_serial->interrupt_in_buffer); + + usb_free_urb(edge_serial->read_urb); + kfree(edge_serial->bulk_in_buffer); + + kfree(edge_serial); + + return response; }