Skip to content

Commit

Permalink
ds2782_battery: Fix signedness bug in ds278x_read_reg16()
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
  • Loading branch information
Dan Carpenter authored and Anton Vorontsov committed Nov 18, 2012
1 parent 08d816b commit 8511748
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/power/ds2782_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 8511748

Please sign in to comment.