All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] USB: serial: mos7840: fix error code in mos7840_write()
@ 2021-01-26 10:26 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2021-01-26 10:26 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Greg Kroah-Hartman, Paul B Schroeder, linux-usb, kernel-janitors

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

Fixes: 3f5429746d91 ("USB: Moschip 7840 USB-Serial Driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/usb/serial/mos7840.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 23f91d658cb4..30c25ef0dacd 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -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);
 
-- 
2.29.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] USB: serial: mos7840: fix error code in mos7840_write()
@ 2021-01-26 10:26 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2021-01-26 10:26 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Greg Kroah-Hartman, Paul B Schroeder, linux-usb, kernel-janitors

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

Fixes: 3f5429746d91 ("USB: Moschip 7840 USB-Serial Driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/usb/serial/mos7840.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 23f91d658cb4..30c25ef0dacd 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -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);
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] USB: serial: mos7840: fix error code in mos7840_write()
  2021-01-26 10:26 ` Dan Carpenter
@ 2021-01-26 14:31   ` Johan Hovold
  -1 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2021-01-26 14:31 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Johan Hovold, Greg Kroah-Hartman, Paul B Schroeder, linux-usb,
	kernel-janitors

On Tue, Jan 26, 2021 at 01:26:54PM +0300, Dan Carpenter wrote:
> This should return -ENOMEM instead of 0 if the kmalloc() fails.
> 
> Fixes: 3f5429746d91 ("USB: Moschip 7840 USB-Serial Driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, thanks.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] USB: serial: mos7840: fix error code in mos7840_write()
@ 2021-01-26 14:31   ` Johan Hovold
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2021-01-26 14:31 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Johan Hovold, Greg Kroah-Hartman, Paul B Schroeder, linux-usb,
	kernel-janitors

On Tue, Jan 26, 2021 at 01:26:54PM +0300, Dan Carpenter wrote:
> This should return -ENOMEM instead of 0 if the kmalloc() fails.
> 
> Fixes: 3f5429746d91 ("USB: Moschip 7840 USB-Serial Driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, thanks.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-26 14:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-26 10:26 [PATCH] USB: serial: mos7840: fix error code in mos7840_write() Dan Carpenter
2021-01-26 10:26 ` Dan Carpenter
2021-01-26 14:31 ` Johan Hovold
2021-01-26 14:31   ` Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.