Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp2934401ybf; Mon, 2 Mar 2020 19:04:28 -0800 (PST) X-Google-Smtp-Source: ADFU+vs6OJPIYXPulYNijdqh3JXoSCkxP7ZVQ8V8ghuy5k9tEL5bIsmVcRf32SMh5fzh26Pghvyy X-Received: by 2002:a05:6808:b13:: with SMTP id s19mr1028704oij.119.1583204668372; Mon, 02 Mar 2020 19:04:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583204668; cv=none; d=google.com; s=arc-20160816; b=Pb4R9SiwCSMHhi/QtI26fKVhvOlMMPfatLhA9xysVuCWT9MEd4Lj4cjJ7Cf+tP4Z5Y rAStx9FbWPeMMSMWE5PlUfqiqJpc3bHg+NxwUQGHKezbeD8NRrJwEJ5wM9MqlPEUYJXZ uRl74AQZlAlA7Eim+dvY2LvQg9MdaYSIOQWOdDfEgN2d0FuiFTNeH3Dz7XkL4aBOga8n aV/JitgNuah4CmAKsRmn6ILrsr0ia8b6RSUuWz4lQEwsIWsO2qpwhZ7nA+VD6xKsMB5U lVD/1X9b84R9oqF7/hoWgN79InhQw6SdGeq68zqTJ8kREQD8JU5L7T/2/osTo8Rh8s6L M/0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VPMHteyNbPK9iuEi5Xp/XrwLI8WN8i+2N18B66+xqfM=; b=EXPS7kwXjSlGGsBqkw7D+dsD0JCfFL3BnXEgf5UNxeO8YCpkkC3b5mH9ndEW7cb0JO JJ4kWK9KGMzvyTWS8taFkiVcqVYnLWjTpjCNjNkZ03ZdAaFT1c5btcG46/5yW2Ac+D3H AqEC8kDbYY8LCB/BtXx12KXjplj7eUo/qGLEneQzpnKLL+mnpFwK8WZE/llTmAJxPJUt U3tJNGJy9z20oKgvdhi+R074dixQwKqEq7W8tYcuv3C06ugNrc96F2PG1g3bbTYGvi7r AhCROLld6RD06GF5xn/10KiLnhfMJRP1Q/OLL+GOc4r/ttfGAYzOQXxwNo9rsEjnqX2t Y4Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r7q6xY4p; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v137si5875303oif.170.2020.03.02.19.04.16; Mon, 02 Mar 2020 19:04:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r7q6xY4p; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727468AbgCCCq1 (ORCPT + 99 others); Mon, 2 Mar 2020 21:46:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:40658 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727425AbgCCCqZ (ORCPT ); Mon, 2 Mar 2020 21:46:25 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C703224682; Tue, 3 Mar 2020 02:46:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583203584; bh=XPgDphCG7o8+2DsQtg+A8h+zRYGpfJPdC/2PvdX86VQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r7q6xY4pw2kjz4HuWXkBTGB+u1cqCDq4P7OFOpHAFlNvy3h28UAyRC0TIfmwL84Tl FdnQzNrd1askHL+B5gg9T9bJUIvGdwXhyOKnibCrDziHZ6iSCe0u2KYAifKJf4DOAD ZiaekaIKGXnZ/F3igxfCcZglnVJaf6AnmSAsiTwc= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Lars-Peter Clausen , Michal Nazarewicz , Alexandru Ardelean , Felipe Balbi , Sasha Levin , linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 5.5 07/66] usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags Date: Mon, 2 Mar 2020 21:45:16 -0500 Message-Id: <20200303024615.8889-7-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200303024615.8889-1-sashal@kernel.org> References: <20200303024615.8889-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lars-Peter Clausen [ Upstream commit 43d565727a3a6fd24e37c7c2116475106af71806 ] ffs_aio_cancel() can be called from both interrupt and thread context. Make sure that the current IRQ state is saved and restored by using spin_{un,}lock_irq{save,restore}(). Otherwise undefined behavior might occur. Acked-by: Michal Nazarewicz Signed-off-by: Lars-Peter Clausen Signed-off-by: Alexandru Ardelean Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/gadget/function/f_fs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index 6f8b67e617716..bdac92d3a8d0c 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1162,18 +1162,19 @@ static int ffs_aio_cancel(struct kiocb *kiocb) { struct ffs_io_data *io_data = kiocb->private; struct ffs_epfile *epfile = kiocb->ki_filp->private_data; + unsigned long flags; int value; ENTER(); - spin_lock_irq(&epfile->ffs->eps_lock); + spin_lock_irqsave(&epfile->ffs->eps_lock, flags); if (likely(io_data && io_data->ep && io_data->req)) value = usb_ep_dequeue(io_data->ep, io_data->req); else value = -EINVAL; - spin_unlock_irq(&epfile->ffs->eps_lock); + spin_unlock_irqrestore(&epfile->ffs->eps_lock, flags); return value; } -- 2.20.1