[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CA+pa1O1bCTgAg=7MFYsF1o2P2UTvppt92x0GfzVvDZ1+Ch-74Q@mail.gmail.com>
Date: Sat, 18 Jan 2020 13:18:20 +0000
From: Michał Nazarewicz <mina86@...a86.com>
To: Alexandru Ardelean <alexandru.ardelean@...log.com>
Cc: USB list <linux-usb@...r.kernel.org>, linux-kernel@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Lars-Peter Clausen <lars@...afoo.de>
Subject: Re: [PATCH][RESEND] usb: gadget: ffs: ffs_aio_cancel(): Save/restore
IRQ flags
On Thu, 16 Jan 2020 at 13:27, Alexandru Ardelean
<alexandru.ardelean@...log.com> wrote:
>
> From: Lars-Peter Clausen <lars@...afoo.de>
>
> 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.
>
> Signed-off-by: Lars-Peter Clausen <lars@...afoo.de>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@...log.com>
Acked-by: Michal Nazarewicz <mina86@...a86.com>
> ---
> 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 6f8b67e61771..bdac92d3a8d0 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
>
--
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»
Powered by blists - more mailing lists