summary refs log tree commit diff
path: root/drivers/usb/serial/iuu_phoenix.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2020-07-25 21:49:36 +0200
committerIngo Molnar <mingo@kernel.org>2020-07-25 21:49:36 +0200
commitc84d53051fcb4f3d14d5a245e1d7ee8512bcb199 (patch)
tree30f7f845afc8e0428c1fbb1bc93f52b120d40661 /drivers/usb/serial/iuu_phoenix.c
parent9a71df495c3d29dab596bb590e73fd8b20106e2d (diff)
parentba47d845d715a010f7b51f6f89bae32845e6acb7 (diff)
downloadlinux-c84d53051fcb4f3d14d5a245e1d7ee8512bcb199.tar.gz
Merge tag 'v5.8-rc6' into locking/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/usb/serial/iuu_phoenix.c')
-rw-r--r--drivers/usb/serial/iuu_phoenix.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c
index d5bff69b1769..b8dfeb4fb2ed 100644
--- a/drivers/usb/serial/iuu_phoenix.c
+++ b/drivers/usb/serial/iuu_phoenix.c
@@ -697,14 +697,16 @@ static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port,
 	struct iuu_private *priv = usb_get_serial_port_data(port);
 	unsigned long flags;
 
-	if (count > 256)
-		return -ENOMEM;
-
 	spin_lock_irqsave(&priv->lock, flags);
 
+	count = min(count, 256 - priv->writelen);
+	if (count == 0)
+		goto out;
+
 	/* fill the buffer */
 	memcpy(priv->writebuf + priv->writelen, buf, count);
 	priv->writelen += count;
+out:
 	spin_unlock_irqrestore(&priv->lock, flags);
 
 	return count;