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]
Date:   Tue, 12 Jun 2018 06:21:05 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Zhouyang Jia <jiazhouyang09@...il.com>
Cc:     Rudolf Marek <r.marek@...embler.cz>,
        Jean Delvare <jdelvare@...e.com>, linux-hwmon@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] hwmon: (w83793) add error handling for i2c_new_dummy

On 06/11/2018 08:32 PM, Zhouyang Jia wrote:
> When i2c_new_dummy fails, the lack of error-handling code may
> cause unexpected results.
> 

There are no unexpected results.

> This patch adds error-handling code after calling i2c_new_dummy.
> 

Making a non-fatal error fatal doesn't serve a useful purpose.

NACK

Guenter

> Signed-off-by: Zhouyang Jia <jiazhouyang09@...il.com>
> ---
>   drivers/hwmon/w83793.c | 15 ++++++++++++++-
>   1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/w83793.c b/drivers/hwmon/w83793.c
> index 0af0f62..4aa3a0e 100644
> --- a/drivers/hwmon/w83793.c
> +++ b/drivers/hwmon/w83793.c
> @@ -1603,8 +1603,15 @@ w83793_detect_subclients(struct i2c_client *client)
>   	}
>   
>   	tmp = w83793_read_value(client, W83793_REG_I2C_SUBADDR);
> -	if (!(tmp & 0x08))
> +	if (!(tmp & 0x08)) {
>   		data->lm75[0] = i2c_new_dummy(adapter, 0x48 + (tmp & 0x7));
> +		if (data->lm75[0] == NULL) {
> +			dev_err(&client->dev,
> +				"Failed to allocate I2C device\n");
> +			err = -ENODEV;
> +			goto ERROR_SC_1;
> +		}
> +	}
>   	if (!(tmp & 0x80)) {
>   		if ((data->lm75[0] != NULL)
>   		    && ((tmp & 0x7) == ((tmp >> 4) & 0x7))) {
> @@ -1616,6 +1623,12 @@ w83793_detect_subclients(struct i2c_client *client)
>   		}
>   		data->lm75[1] = i2c_new_dummy(adapter,
>   					      0x48 + ((tmp >> 4) & 0x7));
> +		if (data->lm75[1] == NULL) {
> +			dev_err(&client->dev,
> +				"Failed to allocate I2C device\n");
> +			err = -ENODEV;
> +			goto ERROR_SC_1;
> +		}
>   	}
>   
>   	return 0;
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ