lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <55E4731F.4070507@kernel.org>
Date:	Mon, 31 Aug 2015 16:30:39 +0100
From:	Jonathan Cameron <jic23@...nel.org>
To:	Dan Carpenter <dan.carpenter@...cle.com>
Cc:	Hartmut Knaack <knaack.h@....de>,
	Lars-Peter Clausen <lars@...afoo.de>,
	Peter Meerwald <pmeerw@...erw.net>,
	Dan Murphy <dmurphy@...com>,
	Krzysztof Kozlowski <k.kozlowski@...sung.com>,
	linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org
Subject: Re: [patch v3] iio: tsl4531: fix error handling in tsl4531_check_id()

On 18/08/15 10:16, Dan Carpenter wrote:
> The tsl4531_check_id() function returned 1 on "found" and 0 on "not
> found" and negative error codes on failure.  This was non-standard and
> bug prone.  The caller treated all non-zero values including error codes
> as "found".
> 
> This patch fixes it by changing the tsl4531_check_id() to return zero on
> success or a negative error code, and updates the caller.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>
Applied to the fixes-togreg branch of iio.git.

Given it's just a slightly different approach to the v2 that
Peter acked, I pulled that ack in here as well.

Thanks,

Jonathan
> ---
> v3: slightly different fix again
> v2: different fix
> 
> diff --git a/drivers/iio/light/tsl4531.c b/drivers/iio/light/tsl4531.c
> index 2697918..cf94ec7 100644
> --- a/drivers/iio/light/tsl4531.c
> +++ b/drivers/iio/light/tsl4531.c
> @@ -158,9 +158,9 @@ static int tsl4531_check_id(struct i2c_client *client)
>  	case TSL45313_ID:
>  	case TSL45315_ID:
>  	case TSL45317_ID:
> -		return 1;
> -	default:
>  		return 0;
> +	default:
> +		return -ENODEV;
>  	}
>  }
>  
> @@ -180,9 +180,10 @@ static int tsl4531_probe(struct i2c_client *client,
>  	data->client = client;
>  	mutex_init(&data->lock);
>  
> -	if (!tsl4531_check_id(client)) {
> +	ret = tsl4531_check_id(client);
> +	if (ret) {
>  		dev_err(&client->dev, "no TSL4531 sensor\n");
> -		return -ENODEV;
> +		return ret;
>  	}
>  
>  	ret = i2c_smbus_write_byte_data(data->client, TSL4531_CONTROL,
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ