: mei bus fix type promotion bugs
Subsystems (3)
PATCH v2 1/2 mei: bus: type promotion bug in mei_nfc_if_version()
In reply to Tomas WinklerFrom: Dan Carpenter <[email protected]>
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.
---
V2: rebase
drivers/misc/mei/bus-fixup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/mei/bus-fixup.c +1 -1
@@ -341,7 +341,7 @@ static int mei_nfc_if_version(struct mei_cl *cl, ret =0 ; bytes_recv =__mei_cl_recv (cl, (u8 *)reply, if_version_length,0 ,0 ); -if (bytes_recv < if_version_length) { +if (bytes_recv <0 || bytes_recv < if_version_length) {dev_err (bus->dev,"Could not read IF version\n" ); ret = -EIO ; goto err;
Signature · 1 line
2.14.4
PATCH 2/2 mei: bus: type promotion bug in mei_fwver()
In reply to Tomas Winklerif __mei_cl_recv() returns a negative then "bytes_recv" type is promoted to a high positive value in comparison with size_t evaluated by MKHI_FWVER_LEN(1). It results in error condition not to be detected.
--- drivers/misc/mei/bus-fixup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/mei/bus-fixup.c +1 -1
@@ -181,7 +181,7 @@ static int mei_fwver(struct mei_cl_device *cldev) ret =0 ; bytes_recv =__mei_cl_recv (cldev->cl, buf,sizeof (buf),0 ,MKHI_RCV_TIMEOUT ); -if (bytes_recv <MKHI_FWVER_LEN (1 )) { +if (bytes_recv <0 || bytes_recv <MKHI_FWVER_LEN (1 )) {/* * Should be at least one version block, * error out if nothing found
Signature · 1 line
2.14.4
cover : mei bus fix type promotion bugs
The first patch is a rebase of Dan's patch over misc-next version of the driver. It should go also to the stable.
Second one fixes a same issue introduced in next cycle:
"mei: expose fw version to sysfs"
Dan Carpenter (1):
mei: bus: type promotion bug in mei_nfc_if_version()
Tomas Winkler (1):
mei: bus: type promotion bug in mei_fwver()
drivers/misc/mei/bus-fixup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.14.4