Linux USB
 help / color / mirror / Atom feed
* [PATCH] USB: storage: ums-realtek: fix error code in rts51x_read_mem()
@ 2022-03-04  7:35 Dan Carpenter
  2022-03-04 14:18 ` Alan Stern
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-03-04  7:35 UTC (permalink / raw)
  To: Alan Stern
  Cc: Greg Kroah-Hartman, Adam Cozzette, linux-usb, usb-storage,
	kernel-janitors

The rts51x_read_mem() function should return negative error codes.
Currently if the kmalloc() fails it returns USB_STOR_TRANSPORT_ERROR (3)
which is treated as success by the callers.

Fixes: 065e60964e29 ("ums_realtek: do not use stack memory for DMA")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/usb/storage/realtek_cr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
index 3789698d9d3c..0c423916d7bf 100644
--- a/drivers/usb/storage/realtek_cr.c
+++ b/drivers/usb/storage/realtek_cr.c
@@ -365,7 +365,7 @@ static int rts51x_read_mem(struct us_data *us, u16 addr, u8 *data, u16 len)
 
 	buf = kmalloc(len, GFP_NOIO);
 	if (buf == NULL)
-		return USB_STOR_TRANSPORT_ERROR;
+		return -ENOMEM;
 
 	usb_stor_dbg(us, "addr = 0x%x, len = %d\n", addr, len);
 
-- 
2.20.1


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

* Re: [PATCH] USB: storage: ums-realtek: fix error code in rts51x_read_mem()
  2022-03-04  7:35 [PATCH] USB: storage: ums-realtek: fix error code in rts51x_read_mem() Dan Carpenter
@ 2022-03-04 14:18 ` Alan Stern
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Stern @ 2022-03-04 14:18 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Greg Kroah-Hartman, Adam Cozzette, linux-usb, usb-storage,
	kernel-janitors

On Fri, Mar 04, 2022 at 10:35:04AM +0300, Dan Carpenter wrote:
> The rts51x_read_mem() function should return negative error codes.
> Currently if the kmalloc() fails it returns USB_STOR_TRANSPORT_ERROR (3)
> which is treated as success by the callers.
> 
> Fixes: 065e60964e29 ("ums_realtek: do not use stack memory for DMA")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---

Acked-by: Alan Stern <stern@rowland.harvard.edu>

>  drivers/usb/storage/realtek_cr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
> index 3789698d9d3c..0c423916d7bf 100644
> --- a/drivers/usb/storage/realtek_cr.c
> +++ b/drivers/usb/storage/realtek_cr.c
> @@ -365,7 +365,7 @@ static int rts51x_read_mem(struct us_data *us, u16 addr, u8 *data, u16 len)
>  
>  	buf = kmalloc(len, GFP_NOIO);
>  	if (buf == NULL)
> -		return USB_STOR_TRANSPORT_ERROR;
> +		return -ENOMEM;
>  
>  	usb_stor_dbg(us, "addr = 0x%x, len = %d\n", addr, len);
>  
> -- 
> 2.20.1
> 

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

end of thread, other threads:[~2022-03-04 14:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-04  7:35 [PATCH] USB: storage: ums-realtek: fix error code in rts51x_read_mem() Dan Carpenter
2022-03-04 14:18 ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox