Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3336406pxf; Mon, 15 Mar 2021 07:25:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuJoR3Vws1cmn8zCVeQDpOz5UQ15QSIrEymUoI6O1a6EecxiX+rCfy37xQ2GRlMmrSfuQ9 X-Received: by 2002:a17:906:c181:: with SMTP id g1mr23209555ejz.96.1615818301632; Mon, 15 Mar 2021 07:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615818301; cv=none; d=google.com; s=arc-20160816; b=ZxrmX4O17N5IbnjpuKF2n5P7/AmWsZPWymUkXarcnjs0hE4fIEBbKZ7pwX5Nck4yiv 6gEnJWYy4SVRqJPO2let+rjIubg63O24wZTgIAaTr90EXn0SJTSp0rMajQdOSL/CB8cL q1uYNjaYSzGULAqfBFTJr3+eY7GSOFeieFEjlRu4qufy+r8xSym98MI+RSrTQBGq62ws HOh89LRblE1aFooGu0aPO6NnQOmNs/NftGhRryOSFv4JMlOElKSTAamcUuaiXN/teVrq vZHmBXdBELVlDKvs80Fn9X6vaBW4Z69YV+o8viASTAWt4HGO46uGAvUIVGihIJZKI/zt KOtA== 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=7gccfc1TSxXi3vHiQPJWEa8P+1VeWkQAl4cW+E+s0J8=; b=uji+1IsgLvi2n08f7wR/3kzh9DPwlJa2c9BTbeSqAawcNZw0RYuyzgYhYZq4tFuMzL 7BAy4nKMYqu1aI98W6zQSKPrmjfO6yfl2v7Nho+6i6nlhxkrxOJlqimSZKephRAjYtf0 DHnyTc+DeNxWKMm+R/ZYK6ZyRm7oELNamUj6/UWgI/XhkLrE1p/8sPSGx5I8EkmN6pgC qJgqpHCuCijQB5TBAaCZDbjxq74dADQrXraOxF0HFR66F3R1anckxBHqRbdoCzhpK3ws MHFooG15k+gIOxMHY6SF7WsVRCiVkO8UlLTj+KNIgiOpxvKxCL95+HqQb2sBp+fjzuYU mBlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nDv97tBv; 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 hp34si11314397ejc.328.2021.03.15.07.24.38; Mon, 15 Mar 2021 07:25:01 -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=nDv97tBv; 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 S237850AbhCOOWK (ORCPT + 99 others); Mon, 15 Mar 2021 10:22:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:37582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232908AbhCOOAJ (ORCPT ); Mon, 15 Mar 2021 10:00:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2EA0D64EF5; Mon, 15 Mar 2021 13:59:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816795; bh=dsjSFKzKR3YF5jmpTtzlvZTNpdzIkImLzudkGKV3LFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nDv97tBvNTdTJSMugbvn+5ip9F7GwbaBbivfsnygAtM5s+DJk84WYsEnDkvDqnbCD ID7vGT9ZvZkKDd2diYjKwUKhOwewu4vApSXycN0LZiR1cq1WirG5G7A5GyqAL4s34E eqmr5cQS+Tujus19s90OJUoOuUmsoMTTNzkJW/qY= 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 5.4 115/168] USB: serial: io_edgeport: fix memory leak in edge_startup Date: Mon, 15 Mar 2021 14:55:47 +0100 Message-Id: <20210315135554.138659127@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@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 @@ -3003,26 +3003,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; }