Skip to content

Commit 5d5a6ad

Browse files
Dan Carpenterbwhacks
authored andcommitted
mei: bus: type promotion bug in mei_nfc_if_version()
commit b40b3e9 upstream. We accidentally removed the check for negative returns without considering the issue of type promotion. The "if_version_length" variable is type size_t so if __mei_cl_recv() returns a negative then "bytes_recv" is type promoted to a high positive value and treated as success. Fixes: 582ab27 ("mei: bus: fix received data size check in NFC fixup") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Tomas Winkler <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> [bwh: Backported to 3.16: adjust filename, context] Signed-off-by: Ben Hutchings <[email protected]>
1 parent acb9ef0 commit 5d5a6ad

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/misc/mei/nfc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ static int mei_nfc_if_version(struct mei_nfc_dev *ndev)
292292
return -ENOMEM;
293293

294294
bytes_recv = __mei_cl_recv(cl, (u8 *)reply, if_version_length);
295-
if (bytes_recv < if_version_length) {
295+
if (bytes_recv < 0 || bytes_recv < if_version_length) {
296296
dev_err(&dev->pdev->dev, "Could not read IF version\n");
297297
ret = -EIO;
298298
goto err;

0 commit comments

Comments
 (0)