2013-07-26 02:15:59

by Wei Yongjun

[permalink] [raw]
Subject: [PATCH -next] staging: gdm724x: use GFP_ATOMIC under spin lock

From: Wei Yongjun <[email protected]>

A spin lock is taken here so we should use GFP_ATOMIC.

Signed-off-by: Wei Yongjun <[email protected]>
---
drivers/staging/gdm724x/gdm_mux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c
index f570bc0..7becf5c 100644
--- a/drivers/staging/gdm724x/gdm_mux.c
+++ b/drivers/staging/gdm724x/gdm_mux.c
@@ -410,7 +410,7 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index,
gdm_mux_send_complete,
t);

- ret = usb_submit_urb(t->urb, GFP_KERNEL);
+ ret = usb_submit_urb(t->urb, GFP_ATOMIC);

spin_unlock_irqrestore(&mux_dev->write_lock, flags);


2013-07-26 07:33:12

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH -next] staging: gdm724x: use GFP_ATOMIC under spin lock

On Fri, Jul 26, 2013 at 10:15:55AM +0800, Wei Yongjun wrote:
> From: Wei Yongjun <[email protected]>
>
> A spin lock is taken here so we should use GFP_ATOMIC.
>

Acked-by: Dan Carpenter <[email protected]>

But the locking here is really odd and pointless. usb_submit_urb()
returns asynchronously before the data has been sent, so there is
almost no point in locking around it.

regards,
dan carpenter

2013-07-26 22:04:16

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH -next] staging: gdm724x: use GFP_ATOMIC under spin lock

On Fri, Jul 26, 2013 at 10:32:33AM +0300, Dan Carpenter wrote:
> On Fri, Jul 26, 2013 at 10:15:55AM +0800, Wei Yongjun wrote:
> > From: Wei Yongjun <[email protected]>
> >
> > A spin lock is taken here so we should use GFP_ATOMIC.
> >
>
> Acked-by: Dan Carpenter <[email protected]>
>
> But the locking here is really odd and pointless. usb_submit_urb()
> returns asynchronously before the data has been sent, so there is
> almost no point in locking around it.

There's no guarantee it will return before the complete() call is made,
so the data could be sent and then received before the call returns.

Not to say that the locking doesn't seem wrong, I agree with that...

thanks,

greg k-h