public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gadget: Fix a sleep-in-atomic bug
@ 2017-05-31  3:13 Jia-Ju Bai
  2017-05-31 10:57 ` Michal Nazarewicz
  0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2017-05-31  3:13 UTC (permalink / raw)
  To: balbi, gregkh, mina86, plr.vincent, felixhaedicke, jilin,
	dan.carpenter
  Cc: linux-usb, linux-kernel, Jia-Ju Bai

The driver may sleep under a spin lock, and the function call path is:
ffs_epfile_io (acquire the lock by spin_lock_irq)
  usb_ep_alloc_request(GFP_KERNEL) --> may sleep

To fix it, the "GFP_KERNEL" is replaced with "GFP_ATOMIC".

Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
---
 drivers/usb/gadget/function/f_fs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 47dda34..be90e25 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -1015,7 +1015,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
 		else
 			ret = ep->status;
 		goto error_mutex;
-	} else if (!(req = usb_ep_alloc_request(ep->ep, GFP_KERNEL))) {
+	} else if (!(req = usb_ep_alloc_request(ep->ep, GFP_ATOMIC))) {
 		ret = -ENOMEM;
 	} else {
 		req->buf      = data;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gadget: Fix a sleep-in-atomic bug
  2017-05-31  3:13 [PATCH] gadget: Fix a sleep-in-atomic bug Jia-Ju Bai
@ 2017-05-31 10:57 ` Michal Nazarewicz
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Nazarewicz @ 2017-05-31 10:57 UTC (permalink / raw)
  To: Jia-Ju Bai, balbi, gregkh, plr.vincent, felixhaedicke, jilin,
	dan.carpenter
  Cc: linux-usb, linux-kernel, Jia-Ju Bai

On Wed, May 31 2017, Jia-Ju Bai wrote:
> The driver may sleep under a spin lock, and the function call path is:
> ffs_epfile_io (acquire the lock by spin_lock_irq)
>   usb_ep_alloc_request(GFP_KERNEL) --> may sleep
>
> To fix it, the "GFP_KERNEL" is replaced with "GFP_ATOMIC".
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>

Acked-by: Michal Nazarewicz <mina86@mina86.com>

> ---
>  drivers/usb/gadget/function/f_fs.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index 47dda34..be90e25 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -1015,7 +1015,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
>  		else
>  			ret = ep->status;
>  		goto error_mutex;
> -	} else if (!(req = usb_ep_alloc_request(ep->ep, GFP_KERNEL))) {
> +	} else if (!(req = usb_ep_alloc_request(ep->ep, GFP_ATOMIC))) {
>  		ret = -ENOMEM;
>  	} else {
>  		req->buf      = data;

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-31 10:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-31  3:13 [PATCH] gadget: Fix a sleep-in-atomic bug Jia-Ju Bai
2017-05-31 10:57 ` Michal Nazarewicz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox