Skip to contentSkip to conversation

media: i2c: fix error check on max9286_read call

PATCH In review Colin King 2 participants 2 messages Jul 20, 2020

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 media: i2c: fix error check on max9286_read call

From: Colin Ian King <[email protected]>

Currently the error return from the call to max9286_read is masked with 0xf0 so the following check for a negative error return is never true. Fix this by checking for an error first, then masking the return value for subsequent conflink_mask checking.

Addresses-Coverity: ("Logically dead code")

Fixes 66d8c9d2422d ("media: i2c: Add MAX9286 driver")
---
 drivers/media/i2c/max9286.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/i2c/max9286.c +2 -1
index 47f280518fdb..b364a3f60486 100644
@@ -405,10 +405,11 @@ static int max9286_check_config_link(struct max9286_priv *priv,
 	 * to 5 milliseconds.
 	 */
 	for (i = 0; i < 10; i++) {
-		ret = max9286_read(priv, 0x49) & 0xf0;
+		ret = max9286_read(priv, 0x49);
 		if (ret < 0)
 			return -EIO;
 
+		ret &= 0xf0;
 		if (ret = conflink_mask)
 			break;
 
Signature · 1 line
2.27.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Colin,

Quoted 6 lines · Colin King

From: Colin Ian King <[email protected]>

Currently the error return from the call to max9286_read is masked with 0xf0 so the following check for a negative error return is never true. Fix this by checking for an error first, then masking the return value for subsequent conflink_mask checking.

Ooops!

Quoted 3 lines

Addresses-Coverity: ("Logically dead code")

Fixes 66d8c9d2422d ("media: i2c: Add MAX9286 driver")

Thanks,

Quoted 22 lines
---
 drivers/media/i2c/max9286.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/i2c/max9286.c +2 -1
index 47f280518fdb..b364a3f60486 100644
@@ -405,10 +405,11 @@ static int max9286_check_config_link(struct max9286_priv *priv,
 	 * to 5 milliseconds.
 	 */
 	for (i = 0; i < 10; i++) {
-		ret = max9286_read(priv, 0x49) & 0xf0;
+		ret = max9286_read(priv, 0x49);
 		if (ret < 0)
 			return -EIO;
 
+		ret &= 0xf0;
 		if (ret = conflink_mask)
 			break;