[PATCH 1/4] staging: ks7010: fix memcmp() bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Call site to memcmp() treats return value as if it were an error code,
it is not. If memcmp() finds inputs to be not the same, an error
return code should be set explicitly.

Correctly handle return value from call to memcmp(), set error code
explicitly.

Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Signed-off-by: Tobin C. Harding <me@xxxxxxxx>
---
 drivers/staging/ks7010/ks7010_sdio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 28b91be..dbb1f05 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -695,8 +695,8 @@ static int ks7010_sdio_data_compare(struct ks_wlan_private *priv, u32 address,
 	if (ret)
 		goto err_free_read_buf;
 
-	ret = memcmp(data, read_buf, size);
-	if (ret) {
+	if (memcmp(data, read_buf, size) != 0) {
+		ret = -EIO;
 		DPRINTK(0, "data compare error (%d)\n", ret);
 		goto err_free_read_buf;
 	}
-- 
2.7.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux