USB: opticon: fix non-atomic allocation in write path
authorJohan Hovold <johan@kernel.org>
Wed, 29 Oct 2014 08:07:31 +0000 (09:07 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 14 Dec 2014 16:23:54 +0000 (16:23 +0000)
commit e681286de221af78fc85db9222b6a203148c005a upstream.

Write may be called from interrupt context so make sure to use
GFP_ATOMIC for all allocations in write.

Fixes: 0d930e51cfe6 ("USB: opticon: Add Opticon OPN2001 write support")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/serial/opticon.c

index d6c5ed6..e629533 100644 (file)
@@ -293,7 +293,7 @@ static int opticon_write(struct tty_struct *tty, struct usb_serial_port *port,
 
        /* The conncected devices do not have a bulk write endpoint,
         * to transmit data to de barcode device the control endpoint is used */
-       dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_NOIO);
+       dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC);
        if (!dr) {
                dev_err(&port->dev, "out of memory\n");
                count = -ENOMEM;