summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobin C. Harding <me@tobin.cc>2017-03-22 11:59:52 +1100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-23 14:27:23 +0100
commit58af272b333eeba428ca53b5b80dbbcf120fe57a (patch)
tree0c8c3ec2b2faf1bdf4eafb75ea31fbdf26873824
parent12eed2f2fb8ff7623295a5f69e22ef247273cd8f (diff)
downloadcachepc-linux-58af272b333eeba428ca53b5b80dbbcf120fe57a.tar.gz
cachepc-linux-58af272b333eeba428ca53b5b80dbbcf120fe57a.zip
staging: ks7010: fix memcmp() bug
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@oracle.com> Signed-off-by: Tobin C. Harding <me@tobin.cc> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/ks7010/ks7010_sdio.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 28b91be8415c..dbb1f0538b48 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;
}