summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2021-01-28 12:35:23 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-03-03 20:22:52 +0300
commit5abbfbe0da0fe639422cad710ef190ad012bcd78 (patch)
tree216c429941b35f8e64bef20cb6656e6b912708ac
parent3f5bbe24acc4bd29832c3e4c77594d28590c70da (diff)
downloadlinux-5abbfbe0da0fe639422cad710ef190ad012bcd78.tar.xz
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: Dan Carpenter <dan.carpenter@oracle.com> Fixes: 0f64478cbc7a ("USB: add USB serial mos7720 driver") Cc: stable@vger.kernel.org Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/usb/serial/mos7720.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index 6dace4800a06..b36de65a0e12 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -1252,8 +1252,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);