Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3354364pxf; Mon, 15 Mar 2021 07:50:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXmJ9WClbjcQ98Y+83JsQ3L80fYO+87yrq0hhd5whwOz0wndXXvEeklSrcLXzyZv5DpfAC X-Received: by 2002:aa7:d4cb:: with SMTP id t11mr30040125edr.202.1615819816615; Mon, 15 Mar 2021 07:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615819816; cv=none; d=google.com; s=arc-20160816; b=WAIWLS05v1AqNTpGJ2IBx+I/BLU4YWRBDiF7EaJkMBU0iww3j99Lz/zXj5J7VCof/7 B4Rbdapf1jWUNhxwx6gphSGVPgc8Sd8dmU5KZdKEWmGzlFQRHOZgP1QEId+Z0rkuioV3 GKw56HUrvVcV7ZTYmakX1bngVFsxwGlqQPVSFYVvaSP3V7Q+jhiz9YBeMCwY9H7Iu3vg 4aox6Wl12WJmeOYKJKJMACZ6eltk6eawd+RJDskjdumrkXe8SIg1fux4sPzOJcESsA4g CQXO1+wt6kYVcLrl2dYGxyxcCuMyHJxlqjclPbhLJ1JIGg/Y/CnnC/fNmDeYTs5zSMOM jk8A== 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=oHZqE0e6rPoidL55H52grtYG5QFQqHXTwRMK6bbrhO7tKLfcPcxDS9a++dffIco7Dj JF29j7ktqoUwxCEk/3oc/DyTwJAb3b5NeTR5YYxffBxNwtzVp0t1rfkG4AqwAb+v7l5e UIHocpUievKIRMMzmUuSswiLMEEv5yDRnevfx1Llevah0r9x2rm9Q7wCnYP2Ls86wjpm Q/4SPywuW4sM0mTylftXEzxMuLBioglzR7IinzweO6CeS8b+VaqPtGzViXeLfKsoCDje WxN5IqHFv2TndLqvtESL2NEVqkabkdUaA2BqiIIf3DmI230RXCb7HCEuuw7hZo6gaA+g I1+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xqvhL3bt; 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 ga1si11461891ejb.647.2021.03.15.07.49.53; Mon, 15 Mar 2021 07:50:16 -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=xqvhL3bt; 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 S240680AbhCOOr5 (ORCPT + 99 others); Mon, 15 Mar 2021 10:47:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:49196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233943AbhCOOCi (ORCPT ); Mon, 15 Mar 2021 10:02:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 264EE64EEE; Mon, 15 Mar 2021 14:02:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816958; bh=dsjSFKzKR3YF5jmpTtzlvZTNpdzIkImLzudkGKV3LFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xqvhL3btktP8ASgdJgo87hFf33vY2jlpZueJt/s+OUKh+inV4dj2pYKP5Gnz+O1Il m6hOh1sry2R3ZAy9cFLZUORjYbIsfX0KQ1hiyvw+ojPTh/ZF5xi15wEZvZDofgOVx+ TM67V1PGBSRRd4axpKxA1uvsGVCkK3Oh5oNXCnrc= 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.10 212/290] USB: serial: io_edgeport: fix memory leak in edge_startup Date: Mon, 15 Mar 2021 14:55:05 +0100 Message-Id: <20210315135549.116883739@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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; }