Skip to content

Commit a70aa7d

Browse files
Dan Carpenterjhovold
authored andcommitted
USB: serial: mos7840: fix error code in mos7840_write()
This should return -ENOMEM instead of 0 if the kmalloc() fails. Fixes: 3f54297 ("USB: Moschip 7840 USB-Serial Driver") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: stable@vger.kernel.org Signed-off-by: Johan Hovold <johan@kernel.org>
1 parent 5f6225a commit a70aa7d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎drivers/usb/serial/mos7840.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,10 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
883883
if (urb->transfer_buffer == NULL) {
884884
urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
885885
GFP_ATOMIC);
886-
if (!urb->transfer_buffer)
886+
if (!urb->transfer_buffer) {
887+
bytes_sent = -ENOMEM;
887888
goto exit;
889+
}
888890
}
889891
transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE);
890892

0 commit comments

Comments
 (0)