Linux-USB Archive on
 help / color / Atom feed
* [PATCH] usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags
@ 2019-11-06 12:02 Alexandru Ardelean
  0 siblings, 0 replies; only message in thread
From: Alexandru Ardelean @ 2019-11-06 12:02 UTC (permalink / raw)
  To: linux-usb, linux-kernel
  Cc: balbi, gregkh, mina86, Lars-Peter Clausen, Alexandru Ardelean

From: Lars-Peter Clausen <>

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

Otherwise undefined behavior might occur.

Signed-off-by: Lars-Peter Clausen <>
Signed-off-by: Alexandru Ardelean <>
 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 59d9d512dcda..ed3bcbb84b95 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -1160,18 +1160,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;
-	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);
 		value = -EINVAL;
-	spin_unlock_irq(&epfile->ffs->eps_lock);
+	spin_unlock_irqrestore(&epfile->ffs->eps_lock, flags);
 	return value;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06 12:02 [PATCH] usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags Alexandru Ardelean

Linux-USB Archive on

Archives are clonable:
	git clone --mirror linux-usb/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-usb linux-usb/ \
	public-inbox-index linux-usb

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone