summaryrefslogtreecommitdiff
path: root/drivers/input/mouse
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2018-08-02 01:57:43 +0300
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2018-08-02 02:05:55 +0300
commitce1d6f22fa69287f877aca37e275c776ed6e6eb5 (patch)
tree57219e88517ae70ccbad12da8268422e09a34c81 /drivers/input/mouse
parent384cf4285b34e08917e3e66603382f2b0c4f6e1b (diff)
downloadlinux-ce1d6f22fa69287f877aca37e275c776ed6e6eb5.tar.xz
Input: elan_i2c_smbus - cast sizeof to int for comparison
Comparing an int to a size, which is unsigned, causes the int to become unsigned, giving the wrong result. i2c_smbus_read_block_data can return the result of i2c_smbus_xfer, whih can return a negative error code. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ int x; expression e,e1; identifier f; @@ *x = f(...); ... when != x = e1 when != if (x < 0 || ...) { ... return ...; } *x < sizeof(e) // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/mouse')
-rw-r--r--drivers/input/mouse/elan_i2c_smbus.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/input/mouse/elan_i2c_smbus.c b/drivers/input/mouse/elan_i2c_smbus.c
index c060d270bc4d..88e315d2cfd3 100644
--- a/drivers/input/mouse/elan_i2c_smbus.c
+++ b/drivers/input/mouse/elan_i2c_smbus.c
@@ -387,7 +387,7 @@ static int elan_smbus_prepare_fw_update(struct i2c_client *client)
len = i2c_smbus_read_block_data(client,
ETP_SMBUS_IAP_PASSWORD_READ,
val);
- if (len < sizeof(u16)) {
+ if (len < (int)sizeof(u16)) {
error = len < 0 ? len : -EIO;
dev_err(dev, "failed to read iap password: %d\n",
error);