From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Jean Delvare <jdelvare@suse.com>, Guenter Roeck <linux@roeck-us.net>
Cc: linux-kernel@vger.kernel.org, lm-sensors@lm-sensors.org,
Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Subject: [PATCH] hwmon: max31790: fix dereference of ERR_PTR
Date: Wed, 16 Sep 2015 19:32:59 +0530 [thread overview]
Message-ID: <1442412179-1547-1-git-send-email-sudipm.mukherjee@gmail.com> (raw)
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@vectorindia.org>
---
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);
--
1.9.1
next reply other threads:[~2015-09-16 14:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-16 14:02 Sudip Mukherjee [this message]
2015-09-16 14:09 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1442412179-1547-1-git-send-email-sudipm.mukherjee@gmail.com \
--to=sudipm.mukherjee@gmail.com \
--cc=jdelvare@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lm-sensors@lm-sensors.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®