iio: light: bh1780: return after write
authorLinus Walleij <linus.walleij@linaro.org>
Thu, 28 Apr 2016 12:02:41 +0000 (14:02 +0200)
committerJonathan Cameron <jic23@kernel.org>
Wed, 4 May 2016 09:53:51 +0000 (10:53 +0100)
When writing a value using direct reg access from debugfs
we need to return and not fall through to reading the
value, lest we'll dereference a NULL pointer.

Cc: Dan Carpenter <dan.carpenter@oracle.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
drivers/iio/light/bh1780.c

index 72b364e4aa727f5908fdd6ccf76902fcfb0ffe66..f83595334ff1e48399547e39fad95f55feafe606 100644 (file)
@@ -84,7 +84,7 @@ static int bh1780_debugfs_reg_access(struct iio_dev *indio_dev,
        int ret;
 
        if (!readval)
-               bh1780_write(bh1780, (u8)reg, (u8)writeval);
+               return bh1780_write(bh1780, (u8)reg, (u8)writeval);
 
        ret = bh1780_read(bh1780, (u8)reg);
        if (ret < 0)