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:	Wed, 16 Sep 2015 07:09:39 -0700
From:	Guenter Roeck <linux@...ck-us.net>
To:	Sudip Mukherjee <sudipm.mukherjee@...il.com>,
	Jean Delvare <jdelvare@...e.com>
Cc:	linux-kernel@...r.kernel.org, lm-sensors@...sensors.org
Subject: Re: [PATCH] hwmon: max31790: fix dereference of ERR_PTR

On 09/16/2015 07:02 AM, Sudip Mukherjee wrote:
> max31790_update_device() return the error code in ERR_PTR. We were
> checking if it has returned error or not but before checking we have
> dereferenced it.
>
> Signed-off-by: Sudip Mukherjee <sudip@...torindia.org>

Good catch. Applied.

Thanks,
Guenter

> ---
>   drivers/hwmon/max31790.c | 8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c
> index f129668..69c0ac8 100644
> --- a/drivers/hwmon/max31790.c
> +++ b/drivers/hwmon/max31790.c
> @@ -174,12 +174,12 @@ static ssize_t get_fan(struct device *dev,
>   {
>   	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
>   	struct max31790_data *data = max31790_update_device(dev);
> -	int sr = get_tach_period(data->fan_dynamics[attr->index]);
> -	int rpm;
> +	int sr, rpm;
>
>   	if (IS_ERR(data))
>   		return PTR_ERR(data);
>
> +	sr = get_tach_period(data->fan_dynamics[attr->index]);
>   	rpm = RPM_FROM_REG(data->tach[attr->index], sr);
>
>   	return sprintf(buf, "%d\n", rpm);
> @@ -190,12 +190,12 @@ static ssize_t get_fan_target(struct device *dev,
>   {
>   	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
>   	struct max31790_data *data = max31790_update_device(dev);
> -	int sr = get_tach_period(data->fan_dynamics[attr->index]);
> -	int rpm;
> +	int sr, rpm;
>
>   	if (IS_ERR(data))
>   		return PTR_ERR(data);
>
> +	sr = get_tach_period(data->fan_dynamics[attr->index]);
>   	rpm = RPM_FROM_REG(data->target_count[attr->index], sr);
>
>   	return sprintf(buf, "%d\n", rpm);
>

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