Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Dan Carpenter and committed by
Linus Torvalds
aec04288 d2e61b8d

+6 -2
+6 -2
drivers/misc/bh1770glc.c
··· 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; ··· 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;