diff mbox series

HID: usbkbd: Avoid GFP_ATOMIC when GFP_KERNEL is possible

Message ID 20210529100357.GA46765@hyeyoo (mailing list archive)
State Mainlined
Commit a3af901c89685acb590b49ce054ea7e3015a770a
Delegated to: Jiri Kosina
Headers show
Series HID: usbkbd: Avoid GFP_ATOMIC when GFP_KERNEL is possible | expand

Commit Message

Hyeonggon Yoo May 29, 2021, 10:03 a.m. UTC
usb_kbd_alloc_mem is called in usb_kbd_probe, which is
not in atomic context. So constraints can be relaxed here.

Use GFP_KERNEL instead of GFP_ATOMIC.

Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
---
 drivers/hid/usbhid/usbkbd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jiri Kosina June 15, 2021, 8:50 a.m. UTC | #1
On Sat, 29 May 2021, Hyeonggon Yoo wrote:

> usb_kbd_alloc_mem is called in usb_kbd_probe, which is
> not in atomic context. So constraints can be relaxed here.
> 
> Use GFP_KERNEL instead of GFP_ATOMIC.
> 
> Signed-off-by: Hyeonggon Yoo <42.hyeyoo@gmail.com>
> ---
>  drivers/hid/usbhid/usbkbd.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c
> index e22434dfc9ef..df02002066ce 100644
> --- a/drivers/hid/usbhid/usbkbd.c
> +++ b/drivers/hid/usbhid/usbkbd.c
> @@ -239,11 +239,11 @@ static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd)
>  		return -1;
>  	if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL)))
>  		return -1;
> -	if (!(kbd->new = usb_alloc_coherent(dev, 8, GFP_ATOMIC, &kbd->new_dma)))
> +	if (!(kbd->new = usb_alloc_coherent(dev, 8, GFP_KERNEL, &kbd->new_dma)))
>  		return -1;
>  	if (!(kbd->cr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL)))
>  		return -1;
> -	if (!(kbd->leds = usb_alloc_coherent(dev, 1, GFP_ATOMIC, &kbd->leds_dma)))
> +	if (!(kbd->leds = usb_alloc_coherent(dev, 1, GFP_KERNEL, &kbd->leds_dma)))
>  		return -1;
>  
>  	return 0;

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/hid/usbhid/usbkbd.c b/drivers/hid/usbhid/usbkbd.c
index e22434dfc9ef..df02002066ce 100644
--- a/drivers/hid/usbhid/usbkbd.c
+++ b/drivers/hid/usbhid/usbkbd.c
@@ -239,11 +239,11 @@  static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd)
 		return -1;
 	if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL)))
 		return -1;
-	if (!(kbd->new = usb_alloc_coherent(dev, 8, GFP_ATOMIC, &kbd->new_dma)))
+	if (!(kbd->new = usb_alloc_coherent(dev, 8, GFP_KERNEL, &kbd->new_dma)))
 		return -1;
 	if (!(kbd->cr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL)))
 		return -1;
-	if (!(kbd->leds = usb_alloc_coherent(dev, 1, GFP_ATOMIC, &kbd->leds_dma)))
+	if (!(kbd->leds = usb_alloc_coherent(dev, 1, GFP_KERNEL, &kbd->leds_dma)))
 		return -1;
 
 	return 0;