diff mbox series

usb: storage: isd200: fix error checks in isd200_{read,write}_config()

Message ID 20240314093136.16386-1-r.smirnov@omp.ru
State New
Headers show
Series usb: storage: isd200: fix error checks in isd200_{read,write}_config() | expand

Commit Message

Roman Smirnov March 14, 2024, 9:31 a.m. UTC
The expression result >= 0 will be true even if usb_stor_ctrl_transfer()
returns an error code. It is necessary to compare result with
USB_STOR_XFER_GOOD.

Found by Linux Verification Center (linuxtesting.org) with Svace.

Signed-off-by: Roman Smirnov <r.smirnov@omp.ru>
Cc: stable@vger.kernel.org
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 drivers/usb/storage/isd200.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Alan Stern March 14, 2024, 5:06 p.m. UTC | #1
On Thu, Mar 14, 2024 at 12:31:36PM +0300, Roman Smirnov wrote:
> The expression result >= 0 will be true even if usb_stor_ctrl_transfer()
> returns an error code. It is necessary to compare result with
> USB_STOR_XFER_GOOD.
> 
> Found by Linux Verification Center (linuxtesting.org) with Svace.
> 
> Signed-off-by: Roman Smirnov <r.smirnov@omp.ru>
> Cc: stable@vger.kernel.org
> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> ---

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

>  drivers/usb/storage/isd200.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
> index 300aeef160e7..2a1531793820 100644
> --- a/drivers/usb/storage/isd200.c
> +++ b/drivers/usb/storage/isd200.c
> @@ -774,7 +774,7 @@ static int isd200_write_config( struct us_data *us )
>  		(void *) &info->ConfigData, 
>  		sizeof(info->ConfigData));
>  
> -	if (result >= 0) {
> +	if (result == USB_STOR_XFER_GOOD) {
>  		usb_stor_dbg(us, "   ISD200 Config Data was written successfully\n");
>  	} else {
>  		usb_stor_dbg(us, "   Request to write ISD200 Config Data failed!\n");
> @@ -816,7 +816,7 @@ static int isd200_read_config( struct us_data *us )
>  		sizeof(info->ConfigData));
>  
>  
> -	if (result >= 0) {
> +	if (result == USB_STOR_XFER_GOOD) {
>  		usb_stor_dbg(us, "   Retrieved the following ISD200 Config Data:\n");
>  #ifdef CONFIG_USB_STORAGE_DEBUG
>  		isd200_log_config(us, info);
> -- 
> 2.34.1
> 
>
diff mbox series

Patch

diff --git a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
index 300aeef160e7..2a1531793820 100644
--- a/drivers/usb/storage/isd200.c
+++ b/drivers/usb/storage/isd200.c
@@ -774,7 +774,7 @@  static int isd200_write_config( struct us_data *us )
 		(void *) &info->ConfigData, 
 		sizeof(info->ConfigData));
 
-	if (result >= 0) {
+	if (result == USB_STOR_XFER_GOOD) {
 		usb_stor_dbg(us, "   ISD200 Config Data was written successfully\n");
 	} else {
 		usb_stor_dbg(us, "   Request to write ISD200 Config Data failed!\n");
@@ -816,7 +816,7 @@  static int isd200_read_config( struct us_data *us )
 		sizeof(info->ConfigData));
 
 
-	if (result >= 0) {
+	if (result == USB_STOR_XFER_GOOD) {
 		usb_stor_dbg(us, "   Retrieved the following ISD200 Config Data:\n");
 #ifdef CONFIG_USB_STORAGE_DEBUG
 		isd200_log_config(us, info);