mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][next] media: i2c: fix error check on max9286_read call
@ 2020-07-20 16:13 Colin King
  2020-07-20 19:04 ` Kieran Bingham
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2020-07-20 16:13 UTC (permalink / raw)
  To: Jacopo Mondi, Kieran Bingham, Laurent Pinchart,
	Niklas Söderlund, Mauro Carvalho Chehab, linux-media
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/media/i2c/max9286.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
index 47f280518fdb..b364a3f60486 100644
--- a/drivers/media/i2c/max9286.c
+++ b/drivers/media/i2c/max9286.c
@@ -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;
 
-- 
2.27.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] media: i2c: fix error check on max9286_read call
  2020-07-20 16:13 [PATCH][next] media: i2c: fix error check on max9286_read call Colin King
@ 2020-07-20 19:04 ` Kieran Bingham
  0 siblings, 0 replies; 2+ messages in thread
From: Kieran Bingham @ 2020-07-20 19:04 UTC (permalink / raw)
  To: Colin King, Jacopo Mondi, Laurent Pinchart,
	Niklas Söderlund, Mauro Carvalho Chehab, linux-media
  Cc: kernel-janitors, linux-kernel

Hi Colin,

On 20/07/2020 17:13, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> 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!

> Addresses-Coverity: ("Logically dead code")
> fixes: 66d8c9d2422d ("media: i2c: Add MAX9286 driver")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Thanks,

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

> ---
>  drivers/media/i2c/max9286.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
> index 47f280518fdb..b364a3f60486 100644
> --- a/drivers/media/i2c/max9286.c
> +++ b/drivers/media/i2c/max9286.c
> @@ -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;
>  
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-20 19:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-20 16:13 [PATCH][next] media: i2c: fix error check on max9286_read call Colin King
2020-07-20 19:04 ` Kieran Bingham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®