From: Dan Carpenter <dan.carpenter@oracle.com>
To: Anton Vorontsov <cbou@mail.ru>
Cc: David Woodhouse <dwmw2@infradead.org>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] ds2782_battery: signedness bug in ds278x_read_reg16()
Date: Wed, 24 Oct 2012 07:12:29 +0000 [thread overview]
Message-ID: <20121024071229.GB2536@elgon.mountain> (raw)
We need to check for negative values before doing the swab16() for the
error handling to work.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/power/ds2782_battery.c b/drivers/power/ds2782_battery.c
index 6bb6e2f..2fa9b6b 100644
--- a/drivers/power/ds2782_battery.c
+++ b/drivers/power/ds2782_battery.c
@@ -80,13 +80,13 @@ static inline int ds278x_read_reg16(struct ds278x_info *info, int reg_msb,
{
int ret;
- ret = swab16(i2c_smbus_read_word_data(info->client, reg_msb));
+ ret = i2c_smbus_read_word_data(info->client, reg_msb);
if (ret < 0) {
dev_err(&info->client->dev, "register read failed\n");
return ret;
}
- *val = ret;
+ *val = swab16(ret);
return 0;
}
next reply other threads:[~2012-10-24 7:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-24 7:12 Dan Carpenter [this message]
2012-11-18 22:47 ` [patch] ds2782_battery: signedness bug in ds278x_read_reg16() Anton Vorontsov
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=20121024071229.GB2536@elgon.mountain \
--to=dan.carpenter@oracle.com \
--cc=cbou@mail.ru \
--cc=dwmw2@infradead.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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