Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa2a8831 authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman
Browse files

USB: serial: mos7840: fix error code in mos7840_write()



commit a70aa7dc60099bbdcbd6faca42a915d80f31161e upstream.

This should return -ENOMEM instead of 0 if the kmalloc() fails.

Fixes: 3f542974 ("USB: Moschip 7840 USB-Serial Driver")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4e33bc5b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1340,9 +1340,11 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port,
	if (urb->transfer_buffer == NULL) {
		urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE,
					       GFP_ATOMIC);
		if (!urb->transfer_buffer)
		if (!urb->transfer_buffer) {
			bytes_sent = -ENOMEM;
			goto exit;
		}
	}
	transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE);

	memcpy(urb->transfer_buffer, current_position, transfer_size);