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] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 04 Dec 2014 06:20:57 -0800
From:	Guenter Roeck <linux@...ck-us.net>
To:	Bartosz Golaszewski <bgolaszewski@...libre.com>
CC:	LKML <linux-kernel@...r.kernel.org>,
	Benoit Cousson <bcousson@...libre.com>,
	Patrick Titiano <ptitiano@...libre.com>,
	LM Sensors <lm-sensors@...sensors.org>
Subject: Re: [PATCH 2/2] hwmon: tmp401: bail-out from tmp401_probe() in case
 of write errors

On 12/04/2014 01:57 AM, Bartosz Golaszewski wrote:
> The return value of i2c_smbus_read_byte_data() is checked in
> tmp401_init_client(), but only a warning is printed and the device is
> registered anyway. This leads to devices being registered even if they
> cannot be physically detected.
>
> Bail-out from probe in case of write errors and notify the user.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@...libre.com>
> ---
>   drivers/hwmon/tmp401.c | 16 ++++++++++------
>   1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c
> index 5a72d7f..75b3210 100644
> --- a/drivers/hwmon/tmp401.c
> +++ b/drivers/hwmon/tmp401.c
> @@ -618,8 +618,8 @@ static const struct attribute_group tmp432_group = {
>    * Begin non sysfs callback code (aka Real code)
>    */
>
> -static void tmp401_init_client(struct tmp401_data *data,
> -			       struct i2c_client *client)
> +static int tmp401_init_client(struct tmp401_data *data,
> +			      struct i2c_client *client)
>   {
>   	int config, config_orig;
>
> @@ -630,8 +630,8 @@ static void tmp401_init_client(struct tmp401_data *data,
>   	/* Start conversions (disable shutdown if necessary) */
>   	config = i2c_smbus_read_byte_data(client, TMP401_CONFIG_READ);
>   	if (config < 0) {
> -		dev_warn(&client->dev, "Initialization failed!\n");
> -		return;
> +		dev_err(&client->dev, "Initialization failed!");
> +		return config;
>   	}
>
>   	config_orig = config;
> @@ -639,6 +639,8 @@ static void tmp401_init_client(struct tmp401_data *data,
>
>   	if (config != config_orig)
>   		i2c_smbus_write_byte_data(client, TMP401_CONFIG_WRITE, config);

No error check and return here ?

Guenter

> +
> +	return 0;
>   }
>
>   static int tmp401_detect(struct i2c_client *client,
> @@ -721,7 +723,7 @@ static int tmp401_probe(struct i2c_client *client,
>   	struct device *dev = &client->dev;
>   	struct device *hwmon_dev;
>   	struct tmp401_data *data;
> -	int groups = 0;
> +	int groups = 0, status;
>
>   	data = devm_kzalloc(dev, sizeof(struct tmp401_data), GFP_KERNEL);
>   	if (!data)
> @@ -732,7 +734,9 @@ static int tmp401_probe(struct i2c_client *client,
>   	data->kind = id->driver_data;
>
>   	/* Initialize the TMP401 chip */
> -	tmp401_init_client(data, client);
> +	status = tmp401_init_client(data, client);
> +	if (status < 0)
> +		return status;
>
>   	/* Register sysfs hooks */
>   	data->groups[groups++] = &tmp401_group;
>

--
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