USB: storage: ums-realtek: fix error code in rts51x_read_mem()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 4 Mar 2022 07:35:04 +0000 (10:35 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Apr 2022 07:08:18 +0000 (09:08 +0200)
[ Upstream commit b07cabb8361dc692522538205552b1b9dab134be ]

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")
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20220304073504.GA26464@kili
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/storage/realtek_cr.c

index 8e0b12cc084a862df3f65777c7680d4ed4fd2970..0c5f1db24ee82122c87cd58477f0c9a07af975e7 100644 (file)
@@ -376,7 +376,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);