Browse Source

iio: light: bh1780: return after write

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>
Linus Walleij 9 years ago
parent
commit
53dfc3b9e6
1 changed files with 1 additions and 1 deletions
  1. 1 1
      drivers/iio/light/bh1780.c

+ 1 - 1
drivers/iio/light/bh1780.c

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