Message ID | 20200501131524.704761628@linuxfoundation.org |
---|---|
State | Superseded |
Headers | show
Return-Path: <SRS0=1/SS=6P=vger.kernel.org=stable-owner@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CD51C4724C for <stable@archiver.kernel.org>; Fri, 1 May 2020 13:26:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D39D208D6 for <stable@archiver.kernel.org>; Fri, 1 May 2020 13:26:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588339578; bh=R6UamDJw4+3i3yj/3AJ3ccIrqCqsDtmzcI8grnRycKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=l0QeMm4jiYEqpsX3NOkfnx0oh5elAUc30pZQWgcngRbLpe8SzGcL+N5TQD4t+7DlN 2t4HAuxW5Y4EGYLPFMX6FL/lHV+IMrz6YRrCuapqJnzX79kg3Z+mum1yQpc+QMiign hcNY/36zD0jZptCjTdJMbrjvIJgnZS/npb/c/BDE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729211AbgEAN0R (ORCPT <rfc822;stable@archiver.kernel.org>); Fri, 1 May 2020 09:26:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:47802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728900AbgEAN0R (ORCPT <rfc822;stable@vger.kernel.org>); Fri, 1 May 2020 09:26:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DEAD620757; Fri, 1 May 2020 13:26:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588339576; bh=R6UamDJw4+3i3yj/3AJ3ccIrqCqsDtmzcI8grnRycKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FpYpwSuUeyUVwwHOcwRWvAzo1pDe3k/2fB9IlqeJSfAe0+85jhDhgxVzpJjO3eIJc 6Oh+YLLTBASRIoChRttlr5VuYBf5Y/QkO0bbW2clvj2G+AmA5tISYRPUlKKrVBJWmq bmuxtwFrfGXD56LgpN6E9nH/O8PGt7GJntdCNzkY= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org, Alan Stern <stern@rowland.harvard.edu>, Kyungtae Kim <kt0755@gmail.com> Subject: [PATCH 4.4 34/70] USB: core: Fix free-while-in-use bug in the USB S-Glibrary Date: Fri, 1 May 2020 15:21:22 +0200 Message-Id: <20200501131524.704761628@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200501131513.302599262@linuxfoundation.org> References: <20200501131513.302599262@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: <stable.vger.kernel.org> X-Mailing-List: stable@vger.kernel.org |
Series |
None
|
expand
|
--- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -584,12 +584,13 @@ void usb_sg_cancel(struct usb_sg_request int i, retval; spin_lock_irqsave(&io->lock, flags); - if (io->status) { + if (io->status || io->count == 0) { spin_unlock_irqrestore(&io->lock, flags); return; } /* shut everything down */ io->status = -ECONNRESET; + io->count++; /* Keep the request alive until we're done */ spin_unlock_irqrestore(&io->lock, flags); for (i = io->entries - 1; i >= 0; --i) { @@ -603,6 +604,12 @@ void usb_sg_cancel(struct usb_sg_request dev_warn(&io->dev->dev, "%s, unlink --> %d\n", __func__, retval); } + + spin_lock_irqsave(&io->lock, flags); + io->count--; + if (!io->count) + complete(&io->complete); + spin_unlock_irqrestore(&io->lock, flags); } EXPORT_SYMBOL_GPL(usb_sg_cancel);