public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] misc/bh1770glc: error handling in bh1770_power_state_store()
@ 2010-10-28  4:41 Dan Carpenter
  2010-10-29 11:27 ` Onkalo Samu
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-10-28  4:41 UTC (permalink / raw)
  To: Samu Onkalo; +Cc: Jonathan Cameron, linux-kernel, kernel-janitors

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>

diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c
index cee632e..d79a972 100644
--- a/drivers/misc/bh1770glc.c
+++ b/drivers/misc/bh1770glc.c
@@ -649,7 +649,7 @@ static ssize_t bh1770_power_state_store(struct device *dev,
 {
 	struct bh1770_chip *chip =  dev_get_drvdata(dev);
 	unsigned long value;
-	size_t ret;
+	ssize_t ret;
 
 	if (strict_strtoul(buf, 0, &value))
 		return -EINVAL;
@@ -659,8 +659,12 @@ static ssize_t bh1770_power_state_store(struct device *dev,
 		pm_runtime_get_sync(dev);
 
 		ret = bh1770_lux_rate(chip, chip->lux_rate_index);
-		ret |= bh1770_lux_interrupt_control(chip, BH1770_ENABLE);
+		if (ret < 0) {
+			pm_runtime_put(dev);
+			goto leave;
+		}
 
+		ret = bh1770_lux_interrupt_control(chip, BH1770_ENABLE);
 		if (ret < 0) {
 			pm_runtime_put(dev);
 			goto leave;

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

* Re: [patch] misc/bh1770glc: error handling in bh1770_power_state_store()
  2010-10-28  4:41 [patch] misc/bh1770glc: error handling in bh1770_power_state_store() Dan Carpenter
@ 2010-10-29 11:27 ` Onkalo Samu
  0 siblings, 0 replies; 2+ messages in thread
From: Onkalo Samu @ 2010-10-29 11:27 UTC (permalink / raw)
  To: ext Dan Carpenter
  Cc: Jonathan Cameron, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org

On Thu, 2010-10-28 at 06:41 +0200, ext Dan Carpenter wrote:
> 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>

Acked-by: Samu Onkalo <samu.p.onkalo@nokia.com>

> 
> diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c
> index cee632e..d79a972 100644
> --- a/drivers/misc/bh1770glc.c
> +++ b/drivers/misc/bh1770glc.c
> @@ -649,7 +649,7 @@ static ssize_t bh1770_power_state_store(struct device *dev,
>  {
>  	struct bh1770_chip *chip =  dev_get_drvdata(dev);
>  	unsigned long value;
> -	size_t ret;
> +	ssize_t ret;
>  
>  	if (strict_strtoul(buf, 0, &value))
>  		return -EINVAL;
> @@ -659,8 +659,12 @@ static ssize_t bh1770_power_state_store(struct device *dev,
>  		pm_runtime_get_sync(dev);
>  
>  		ret = bh1770_lux_rate(chip, chip->lux_rate_index);
> -		ret |= bh1770_lux_interrupt_control(chip, BH1770_ENABLE);
> +		if (ret < 0) {
> +			pm_runtime_put(dev);
> +			goto leave;
> +		}
>  
> +		ret = bh1770_lux_interrupt_control(chip, BH1770_ENABLE);
>  		if (ret < 0) {
>  			pm_runtime_put(dev);
>  			goto leave;


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

end of thread, other threads:[~2010-10-29 11:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-28  4:41 [patch] misc/bh1770glc: error handling in bh1770_power_state_store() Dan Carpenter
2010-10-29 11:27 ` Onkalo Samu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox