* [PATCH] usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags
@ 2019-11-06 12:02 Alexandru Ardelean
2020-01-16 11:13 ` Ardelean, Alexandru
2020-01-16 13:29 ` [PATCH][RESEND] " Alexandru Ardelean
0 siblings, 2 replies; 6+ messages 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 <lars@metafoo.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@metafoo.de>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.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 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;
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags
2019-11-06 12:02 [PATCH] usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags Alexandru Ardelean
@ 2020-01-16 11:13 ` Ardelean, Alexandru
2020-01-16 13:04 ` Felipe Balbi
2020-01-16 13:29 ` [PATCH][RESEND] " Alexandru Ardelean
1 sibling, 1 reply; 6+ messages in thread
From: Ardelean, Alexandru @ 2020-01-16 11:13 UTC (permalink / raw
To: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: gregkh@linuxfoundation.org, mina86@mina86.com, lars@metafoo.de,
balbi@kernel.org
On Wed, 2019-11-06 at 14:02 +0200, Alexandru Ardelean wrote:
> From: Lars-Peter Clausen <lars@metafoo.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.
Hey,
This is a patch-ping.
Thanks
Alex
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.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 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;
>
> 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;
> }
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags
2020-01-16 11:13 ` Ardelean, Alexandru
@ 2020-01-16 13:04 ` Felipe Balbi
2020-01-16 13:05 ` Ardelean, Alexandru
0 siblings, 1 reply; 6+ messages in thread
From: Felipe Balbi @ 2020-01-16 13:04 UTC (permalink / raw
To: Ardelean, Alexandru, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: gregkh@linuxfoundation.org, mina86@mina86.com, lars@metafoo.de
[-- Attachment #1: Type: text/plain, Size: 605 bytes --]
Hi,
"Ardelean, Alexandru" <alexandru.Ardelean@analog.com> writes:
> On Wed, 2019-11-06 at 14:02 +0200, Alexandru Ardelean wrote:
>> From: Lars-Peter Clausen <lars@metafoo.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.
>
> Hey,
>
> This is a patch-ping.
Please read:
https://lore.kernel.org/linux-usb/875zhd6pw0.fsf@kernel.org/T/#u
We're gonna need a resend, sorry
--
balbi
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags
2020-01-16 13:04 ` Felipe Balbi
@ 2020-01-16 13:05 ` Ardelean, Alexandru
0 siblings, 0 replies; 6+ messages in thread
From: Ardelean, Alexandru @ 2020-01-16 13:05 UTC (permalink / raw
To: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
balbi@kernel.org
Cc: gregkh@linuxfoundation.org, mina86@mina86.com, lars@metafoo.de
On Thu, 2020-01-16 at 15:04 +0200, Felipe Balbi wrote:
> [External]
>
>
> Hi,
>
> "Ardelean, Alexandru" <alexandru.Ardelean@analog.com> writes:
>
> > On Wed, 2019-11-06 at 14:02 +0200, Alexandru Ardelean wrote:
> > > From: Lars-Peter Clausen <lars@metafoo.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.
> >
> > Hey,
> >
> > This is a patch-ping.
>
> Please read:
>
> https://lore.kernel.org/linux-usb/875zhd6pw0.fsf@kernel.org/T/#u
>
> We're gonna need a resend, sorry
>
Ack.
Thanks for the reply.
Will re-send.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH][RESEND] usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags
2019-11-06 12:02 [PATCH] usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags Alexandru Ardelean
2020-01-16 11:13 ` Ardelean, Alexandru
@ 2020-01-16 13:29 ` Alexandru Ardelean
2020-01-18 13:18 ` Michał Nazarewicz
1 sibling, 1 reply; 6+ messages in thread
From: Alexandru Ardelean @ 2020-01-16 13:29 UTC (permalink / raw
To: linux-usb, linux-kernel
Cc: mina86, gregkh, Lars-Peter Clausen, Alexandru Ardelean
From: Lars-Peter Clausen <lars@metafoo.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@metafoo.de>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH][RESEND] usb: gadget: ffs: ffs_aio_cancel(): Save/restore IRQ flags
2020-01-16 13:29 ` [PATCH][RESEND] " Alexandru Ardelean
@ 2020-01-18 13:18 ` Michał Nazarewicz
0 siblings, 0 replies; 6+ messages in thread
From: Michał Nazarewicz @ 2020-01-18 13:18 UTC (permalink / raw
To: Alexandru Ardelean
Cc: USB list, linux-kernel, Greg Kroah-Hartman, Lars-Peter Clausen
On Thu, 16 Jan 2020 at 13:27, Alexandru Ardelean
<alexandru.ardelean@analog.com> wrote:
>
> From: Lars-Peter Clausen <lars@metafoo.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@metafoo.de>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Acked-by: Michal Nazarewicz <mina86@mina86.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»
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-01-18 13:18 UTC | newest]
Thread overview: 6+ messages (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
2020-01-16 11:13 ` Ardelean, Alexandru
2020-01-16 13:04 ` Felipe Balbi
2020-01-16 13:05 ` Ardelean, Alexandru
2020-01-16 13:29 ` [PATCH][RESEND] " Alexandru Ardelean
2020-01-18 13:18 ` Michał Nazarewicz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.