Skip to content

Commit

Permalink
USB: serial: mos7720: fix error code in mos7720_write()
Browse files Browse the repository at this point in the history
This code should return -ENOMEM if the kmalloc() fails but instead
it returns success.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 0f64478 ("USB: add USB serial mos7720 driver")
Cc: stable@vger.kernel.org
Signed-off-by: Johan Hovold <johan@kernel.org>
  • Loading branch information
Dan Carpenter authored and Johan Hovold committed Jan 28, 2021
1 parent 55317e2 commit fea7372
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/usb/serial/mos7720.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,8 +1094,10 @@ 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);

Expand Down

0 comments on commit fea7372

Please sign in to comment.