linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: light: bh1780: return after write
@ 2016-04-28 12:02 Linus Walleij
  2016-05-01 19:42 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2016-04-28 12:02 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio; +Cc: Linus Walleij, Dan Carpenter

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>
---
 drivers/iio/light/bh1780.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/light/bh1780.c b/drivers/iio/light/bh1780.c
index 72b364e4aa72..f83595334ff1 100644
--- a/drivers/iio/light/bh1780.c
+++ b/drivers/iio/light/bh1780.c
@@ -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)
-- 
2.4.11


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: light: bh1780: return after write
  2016-04-28 12:02 [PATCH] iio: light: bh1780: return after write Linus Walleij
@ 2016-05-01 19:42 ` Jonathan Cameron
  2016-05-04  9:54   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2016-05-01 19:42 UTC (permalink / raw)
  To: Linus Walleij, linux-iio; +Cc: Dan Carpenter

On 28/04/16 13:02, Linus Walleij wrote:
> 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>
This is another one I'll have to pick up when I can create a fixes branch for
post the merge window.

Poke me if I forget it.

Jonathan
> ---
>  drivers/iio/light/bh1780.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/light/bh1780.c b/drivers/iio/light/bh1780.c
> index 72b364e4aa72..f83595334ff1 100644
> --- a/drivers/iio/light/bh1780.c
> +++ b/drivers/iio/light/bh1780.c
> @@ -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)
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: light: bh1780: return after write
  2016-05-01 19:42 ` Jonathan Cameron
@ 2016-05-04  9:54   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2016-05-04  9:54 UTC (permalink / raw)
  To: Linus Walleij, linux-iio; +Cc: Dan Carpenter

On 01/05/16 20:42, Jonathan Cameron wrote:
> On 28/04/16 13:02, Linus Walleij wrote:
>> 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>
> This is another one I'll have to pick up when I can create a fixes branch for
> post the merge window.
> 
> Poke me if I forget it.
> 
Applied to the fixes-togreg-post-rc1 branch of iio.git and not
pushed out for a few days (depending on battery of laptop vs free
wifi at Gare du Nord later)

Jonathan
> Jonathan
>> ---
>>  drivers/iio/light/bh1780.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/light/bh1780.c b/drivers/iio/light/bh1780.c
>> index 72b364e4aa72..f83595334ff1 100644
>> --- a/drivers/iio/light/bh1780.c
>> +++ b/drivers/iio/light/bh1780.c
>> @@ -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)
>>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-05-04 14:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-28 12:02 [PATCH] iio: light: bh1780: return after write Linus Walleij
2016-05-01 19:42 ` Jonathan Cameron
2016-05-04  9:54   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).