lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 26 Aug 2020 06:53:37 -0700
From:   trix@...hat.com
To:     arnd@...db.de, gregkh@...uxfoundation.org,
        rikard.falkeborn@...il.com, rogerable@...ltek.com,
        lee.jones@...aro.org
Cc:     linux-kernel@...r.kernel.org, Tom Rix <trix@...hat.com>
Subject: [PATCH] misc: rtsx: improve status check

From: Tom Rix <trix@...hat.com>

clang static analysis flags this error

rtsx_usb.c:505:10: warning: The left operand of '&'
  is a garbage value
        if (val & cd_mask[card])
            ~~~ ^

val is set when rtsx_usb_get_card_status() is successful.  The
problem is how it checks its callers returns.

	/* usb_control_msg may return positive when success */
	if (ret < 0)
		return ret;

This is correct for the usb_control_msg() the call. However,
the call to rtsx_usb_get_status_with_bulk is only successful
when 0 is returned.

So make status checking block specific.

Fixes: 730876be2566 ("mfd: Add realtek USB card reader driver")
Signed-off-by: Tom Rix <trix@...hat.com>
---
 drivers/misc/cardreader/rtsx_usb.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/cardreader/rtsx_usb.c b/drivers/misc/cardreader/rtsx_usb.c
index 59eda55d92a3..bd392b0c66af 100644
--- a/drivers/misc/cardreader/rtsx_usb.c
+++ b/drivers/misc/cardreader/rtsx_usb.c
@@ -304,14 +304,15 @@ int rtsx_usb_get_card_status(struct rtsx_ucr *ucr, u16 *status)
 		*status = *buf;
 
 		kfree(buf);
+
+		/* usb_control_msg may return positive when success */
+		if (ret < 0)
+			return ret;
 	} else {
 		ret = rtsx_usb_get_status_with_bulk(ucr, status);
+		if (ret)
+			return ret;
 	}
-
-	/* usb_control_msg may return positive when success */
-	if (ret < 0)
-		return ret;
-
 	return 0;
 }
 EXPORT_SYMBOL_GPL(rtsx_usb_get_card_status);
-- 
2.18.1

Powered by blists - more mailing lists