Skip to contentSkip to conversation

input: misc: keyspan_remote: Replace GFP_ATOMIC with GFP_KERNEL in keyspan_probe()

PATCH Applied Jia-Ju Bai 2 participants 2 messages Jul 27, 2018

Subsystems (2)
lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

PATCH 1/1 input: misc: keyspan_remote: Replace GFP_ATOMIC with GFP_KERNEL in keyspan_probe()

keyspan_probe() is never called in atomic context.
It calls usb_alloc_coherent() with GFP_ATOMIC, which is not necessary. GFP_ATOMIC can be replace with GFP_KERNEL.

This is found by a static analysis tool named DCNS written by myself.

---
 drivers/input/misc/keyspan_remote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/misc/keyspan_remote.c +1 -1
index 67482b248b2d..a8937ceac66a 100644
@@ -466,7 +466,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
 	remote->in_endpoint = endpoint;
 	remote->toggle = -1;	/* Set to -1 so we will always not match the toggle from the first remote message. */
 
-	remote->in_buffer = usb_alloc_coherent(udev, RECV_SIZE, GFP_ATOMIC, &remote->in_dma);
+	remote->in_buffer = usb_alloc_coherent(udev, RECV_SIZE, GFP_KERNEL, &remote->in_dma);
 	if (!remote->in_buffer) {
 		error = -ENOMEM;
 		goto fail1;
Signature · 1 line
2.17.0
maintainer Applied
#1 lore raw
Quoted 7 lines · Jia-Ju Bai

keyspan_probe() is never called in atomic context.
It calls usb_alloc_coherent() with GFP_ATOMIC, which is not necessary. GFP_ATOMIC can be replace with GFP_KERNEL.

This is found by a static analysis tool named DCNS written by myself.

Applied, thank you.

Quoted 20 lines
---
 drivers/input/misc/keyspan_remote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/misc/keyspan_remote.c +1 -1
index 67482b248b2d..a8937ceac66a 100644
@@ -466,7 +466,7 @@ static int keyspan_probe(struct usb_interface *interface, const struct usb_devic
 	remote->in_endpoint = endpoint;
 	remote->toggle = -1;	/* Set to -1 so we will always not match the toggle from the first remote message. */
 
-	remote->in_buffer = usb_alloc_coherent(udev, RECV_SIZE, GFP_ATOMIC, &remote->in_dma);
+	remote->in_buffer = usb_alloc_coherent(udev, RECV_SIZE, GFP_KERNEL, &remote->in_dma);
 	if (!remote->in_buffer) {
 		error = -ENOMEM;
 		goto fail1;
Signature · 1 line
2.17.0
Signature · 1 line
Dmitry