From patchwork Fri May 1 13:21:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 226656 Return-Path: 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 97CCFC47253 for ; Fri, 1 May 2020 13:34:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6BE6F24955 for ; Fri, 1 May 2020 13:34:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588340065; bh=BL+iUwzCf3163pq7lcS691f60h7nMcprI631MupoxuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=0/mvC1lkuD1sVUR8kAL5oLhh/ajjzJlrq0dfYAPQPwL7MIbU/uUBgI6BNnAXRxF6x Cj5TcH9oLI+C0ug70yuWNvzrDGaEvRRZv1WZyi0x7Dz9/plYSvHMyf+i6vr9CrvFfG zwT2vFjKS6dv/NZ5/u/xKAy5bbsOt/7ZfJYKyzxY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729662AbgEANeX (ORCPT ); Fri, 1 May 2020 09:34:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:60470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730553AbgEANeS (ORCPT ); Fri, 1 May 2020 09:34:18 -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 9CDD824954; Fri, 1 May 2020 13:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588340058; bh=BL+iUwzCf3163pq7lcS691f60h7nMcprI631MupoxuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0jB18A/2V7mpy02WKQlQLCvdIFF4NdSU5bRpyWFeZAMNtZhZlC5mB8YlCkUHHB7iI B83SeVG1rvnMmlGKGQnMx/1TqOmT6MIeppjh36IcEF5kJgzhU+Qj9OzKabF6yST0Xi UglaTwamuLH//LnmjfOkpDYfL3YYz6e5lrgleb6o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Neukum , Jonas Karlsson Subject: [PATCH 4.14 077/117] cdc-acm: close race betrween suspend() and acm_softint Date: Fri, 1 May 2020 15:21:53 +0200 Message-Id: <20200501131554.085402615@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200501131544.291247695@linuxfoundation.org> References: <20200501131544.291247695@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Oliver Neukum commit 0afccd7601514c4b83d8cc58c740089cc447051d upstream. Suspend increments a counter, then kills the URBs, then kills the scheduled work. The scheduled work, however, may reschedule the URBs. Fix this by having the work check the counter. Signed-off-by: Oliver Neukum Cc: stable Tested-by: Jonas Karlsson Link: https://lore.kernel.org/r/20200415151358.32664-1-oneukum@suse.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/cdc-acm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -575,14 +575,14 @@ static void acm_softint(struct work_stru struct acm *acm = container_of(work, struct acm, work); if (test_bit(EVENT_RX_STALL, &acm->flags)) { - if (!(usb_autopm_get_interface(acm->data))) { + smp_mb(); /* against acm_suspend() */ + if (!acm->susp_count) { for (i = 0; i < acm->rx_buflimit; i++) usb_kill_urb(acm->read_urbs[i]); usb_clear_halt(acm->dev, acm->in); acm_submit_read_urbs(acm, GFP_KERNEL); - usb_autopm_put_interface(acm->data); + clear_bit(EVENT_RX_STALL, &acm->flags); } - clear_bit(EVENT_RX_STALL, &acm->flags); } if (test_and_clear_bit(EVENT_TTY_WAKEUP, &acm->flags))