Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3526473pxf; Mon, 15 Mar 2021 11:31:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8SipkWrq3CMuMwhAWvX5MqoC00Ump88m6eB0btzMBKyvR30TXBGvpKzQPmYp1yWZFqMpo X-Received: by 2002:a17:906:495a:: with SMTP id f26mr24677722ejt.271.1615833082491; Mon, 15 Mar 2021 11:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833082; cv=none; d=google.com; s=arc-20160816; b=noLIMxlytj8v9g/MgL6zJgwhZLJnerFhaeYZLMydYr1AkCqF2ASEP0cvJe+Z3H8l0B I3y9FaURIpd4OHMIixjrb04qpxaYb52qy6ofyyR7I8Buk/6Zpxh0Kkx8L08sLMzJAEQe 3aN04oYe0wY8KCRSgJslyjUqbYrZcnDc9F/BC/ahjzoUlnt4vEBnxhrH/fbh/AKVOXYv CeykLu798OUmIStav7yDajCGnUDfPbDC2hsZOcLplyYBVKAljbX5Fzs84yX7WzEuA4P7 aoCs6a8h5mnTdIXMk+WM6KWkxMP2CI8bz3At+gaYKTkz7YTh+p6+6RIev2XB2SRWiiew Q6Nw== 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=V9uWKSkAVR9fah10YGwySUY71/Yjj7usID2gibc2yA+5PboSQHBpG0AKQ7vfMhqTFY +fbyr01uQKGapmHSCD8TKZNu28PXBG2IsAK4y0B+Ur4E4MkYS04lA9Cqxozo3C01V3hj eczAaFdY1rHUZebbtcexGIw3948uSU63/mzUXqxw/UlH0p2lkySa+C5u9dmUtf9miC+N Wjug1Pw4gI8c8B83iWSZvVZid5ZsqKKqbQ2/vg3rABMqYrR6KPZFCKy/oVpUsBtoUjsi /Igq4X7kZEe4HiM0eoKlmx6A9m5kHsO7uba0jIhCACxj0LVy77eCsV5Y2hMOq0jQCMr7 v1UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dNLGzex1; 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 n19si11318488edr.388.2021.03.15.11.31.00; Mon, 15 Mar 2021 11:31:22 -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=dNLGzex1; 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 S240830AbhCOOia (ORCPT + 99 others); Mon, 15 Mar 2021 10:38:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:48938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233666AbhCOOCR (ORCPT ); Mon, 15 Mar 2021 10:02:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2976364F16; Mon, 15 Mar 2021 14:02:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816928; bh=dsjSFKzKR3YF5jmpTtzlvZTNpdzIkImLzudkGKV3LFs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dNLGzex10qIf7Ujrc2HNLnbYQueX9I5lzgx5wmkopr7XjLm592UhuhZ/mdXvohyFR 43GnokNpF90d3rr4T6UjkaUZRsMjQuLNhYYn61PHz5TExOdqfPFnrwDW6LBkbUXoXE rp8TZpiD/KibNWTUldNO/+DN23Z0WDHJ1N7DPAKk= 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.11 208/306] USB: serial: io_edgeport: fix memory leak in edge_startup Date: Mon, 15 Mar 2021 14:54:31 +0100 Message-Id: <20210315135514.660111757@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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; }