From patchwork Tue Apr 28 18:25:19 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: 226856 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=unavailable 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 E867AC83004 for ; Tue, 28 Apr 2020 18:45:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5AD0206A1 for ; Tue, 28 Apr 2020 18:45:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588099512; bh=7xVgDV7w9rdftUuK97B4AsTEKTfHRZIusr+xcQnB9cc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=tiqOi1h9oJ8n8RmIaxFy3yTKoI9mgr0NDi7HgUSQwSFdydHSzLOEfhenmZ8zdc8TU SOMyJQQzmpkT/3AMGvcpVrdFo2zcnb9f+36LOtqM3uEGztN0Wg3u7R3/fPDFwEm41P mN7k+jyumCiif2mzFxkZHrk3QWC6UR29BadycnvE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731541AbgD1So5 (ORCPT ); Tue, 28 Apr 2020 14:44:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:38056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730788AbgD1So4 (ORCPT ); Tue, 28 Apr 2020 14:44:56 -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 B86EF206D6; Tue, 28 Apr 2020 18:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588099496; bh=7xVgDV7w9rdftUuK97B4AsTEKTfHRZIusr+xcQnB9cc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nD0r2cXNIqpdoYKaZsaOLT8Jl4ecI2XR9HIXEQ8TO06gFfO3AM7WY5is/0aDPm1u4 vCH5JKc+6zqwokJbq5xI6UH19ORAmPpd2Kh8uarTck/tXFY21A57d1nOZ/wUTVXwtV 3j3g/FCb330YNnYM9GTbSwhBTxCxVGaklZIpsNWs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oliver Neukum , Jonas Karlsson Subject: [PATCH 5.4 145/168] cdc-acm: close race betrween suspend() and acm_softint Date: Tue, 28 Apr 2020 20:25:19 +0200 Message-Id: <20200428182249.983591588@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200428182231.704304409@linuxfoundation.org> References: <20200428182231.704304409@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 @@ -557,14 +557,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))