Skip to content

Commit

Permalink
drivers/misc/bh1770glc.c: error handling in bh1770_power_state_store()
Browse files Browse the repository at this point in the history
There was a signedness bug so "ret" was never less than zero and that
breaks the error handling.  Also in the original code it would overwrite
ret and the result is still negative but it's bogus number instead of the
correct error code.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Cc: Samu Onkalo <samu.p.onkalo@nokia.com>
Cc: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
error27 authored and torvalds committed Nov 12, 2010
1 parent d2e61b8 commit aec0428
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/misc/bh1770glc.c
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ static ssize_t bh1770_power_state_store(struct device *dev,
{
struct bh1770_chip *chip = dev_get_drvdata(dev);
unsigned long value;
size_t ret;
ssize_t ret;

if (strict_strtoul(buf, 0, &value))
return -EINVAL;
Expand All @@ -659,8 +659,12 @@ static ssize_t bh1770_power_state_store(struct device *dev,
pm_runtime_get_sync(dev);

ret = bh1770_lux_rate(chip, chip->lux_rate_index);
ret |= bh1770_lux_interrupt_control(chip, BH1770_ENABLE);
if (ret < 0) {
pm_runtime_put(dev);
goto leave;
}

ret = bh1770_lux_interrupt_control(chip, BH1770_ENABLE);
if (ret < 0) {
pm_runtime_put(dev);
goto leave;
Expand Down

0 comments on commit aec0428

Please sign in to comment.