Skip to contentSkip to conversation

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

PATCH Applied Dan Carpenter 2 participants 2 messages Jan 26, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: serial: mos7840: fix error code in mos7840_write()

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

Fixes 3f5429746d91 ("USB: Moschip 7840 USB-Serial Driver")
---
 drivers/usb/serial/mos7840.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/serial/mos7840.c +3 -1
index 23f91d658cb4..30c25ef0dacd 100644
@@ -883,8 +883,10 @@ 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);
 
Signature · 1 line
2.29.2
maintainer Applied
#1 lore raw
Quoted 4 lines · Dan Carpenter

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

Fixes 3f5429746d91 ("USB: Moschip 7840 USB-Serial Driver")

Applied, thanks.

Johan