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

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

USB: serial: mos7720: fix error code in mos7720_write()



commit fea7372cbc40869876df0f045e367f6f97a1666c upstream.

This code should return -ENOMEM if the kmalloc() fails but instead
it returns success.

Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Fixes: 0f64478c ("USB: add USB serial mos7720 driver")
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 fa2a8831
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1250,9 +1250,11 @@ static int mos7720_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);