Commit aec04288904a7308f2900926902040e7a69ae2be
Committed by
Linus Torvalds
1 parent
d2e61b8dc9
Exists in
master
and in
39 other branches
drivers/misc/bh1770glc.c: error handling in bh1770_power_state_store()
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>
Showing 1 changed file with 6 additions and 2 deletions Side-by-side Diff
drivers/misc/bh1770glc.c
... | ... | @@ -649,7 +649,7 @@ |
649 | 649 | { |
650 | 650 | struct bh1770_chip *chip = dev_get_drvdata(dev); |
651 | 651 | unsigned long value; |
652 | - size_t ret; | |
652 | + ssize_t ret; | |
653 | 653 | |
654 | 654 | if (strict_strtoul(buf, 0, &value)) |
655 | 655 | return -EINVAL; |
656 | 656 | |
... | ... | @@ -659,8 +659,12 @@ |
659 | 659 | pm_runtime_get_sync(dev); |
660 | 660 | |
661 | 661 | ret = bh1770_lux_rate(chip, chip->lux_rate_index); |
662 | - ret |= bh1770_lux_interrupt_control(chip, BH1770_ENABLE); | |
662 | + if (ret < 0) { | |
663 | + pm_runtime_put(dev); | |
664 | + goto leave; | |
665 | + } | |
663 | 666 | |
667 | + ret = bh1770_lux_interrupt_control(chip, BH1770_ENABLE); | |
664 | 668 | if (ret < 0) { |
665 | 669 | pm_runtime_put(dev); |
666 | 670 | goto leave; |