lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20151123162159.GC807@x1>
Date:	Mon, 23 Nov 2015 16:22:49 +0000
From:	Lee Jones <lee.jones@...aro.org>
To:	Arnd Bergmann <arnd@...db.de>
Cc:	Jingoo Han <jingoohan1@...il.com>,
	Michael Hennerich <michael.hennerich@...log.com>,
	Jean-Christophe Plagniol-Villard <plagnioj@...osoft.com>,
	Tomi Valkeinen <tomi.valkeinen@...com>,
	linux-fbdev@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH] backlight: adp88x0: fix uninitialized variable use

On Mon, 23 Nov 2015, Arnd Bergmann wrote:

> gcc correctly warns about both the adp8860 and adp8870 backlight
> drivers using an uninitialized variable in their error handling
> path:
> 
> drivers/video/backlight/adp8870_bl.c: In function 'adp8870_bl_ambient_light_zone_store':
> drivers/video/backlight/adp8870_bl.c:811:11: warning: 'reg_val' may be used uninitialized in this function
> 
> This changes the code to only write back the data if it was
> correctly read to start with.
> 
> As a side-note, the drivers are mostly identical, so I think they
> should really be merged into one file to avoid having to fix every
> bug twice.
> 
> Signed-off-by: Arnd Bergmann <arnd@...db.de>

Applied with the $SUBJECT line fixed.

> diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
> index 98ffe71e8af2..f0d4c0324580 100644
> --- a/drivers/video/backlight/adp8860_bl.c
> +++ b/drivers/video/backlight/adp8860_bl.c
> @@ -621,10 +621,12 @@ static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev,
>  
>  		/* Set user supplied ambient light zone */
>  		mutex_lock(&data->lock);
> -		adp8860_read(data->client, ADP8860_CFGR, &reg_val);
> -		reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT);
> -		reg_val |= (val - 1) << CFGR_BLV_SHIFT;
> -		adp8860_write(data->client, ADP8860_CFGR, reg_val);
> +		ret = adp8860_read(data->client, ADP8860_CFGR, &reg_val);
> +		if (!ret) {
> +			reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT);
> +			reg_val |= (val - 1) << CFGR_BLV_SHIFT;
> +			adp8860_write(data->client, ADP8860_CFGR, reg_val);
> +		}
>  		mutex_unlock(&data->lock);
>  	}
>  
> diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
> index 9d738352d7d4..21acac90fd77 100644
> --- a/drivers/video/backlight/adp8870_bl.c
> +++ b/drivers/video/backlight/adp8870_bl.c
> @@ -807,10 +807,12 @@ static ssize_t adp8870_bl_ambient_light_zone_store(struct device *dev,
>  
>  		/* Set user supplied ambient light zone */
>  		mutex_lock(&data->lock);
> -		adp8870_read(data->client, ADP8870_CFGR, &reg_val);
> -		reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT);
> -		reg_val |= (val - 1) << CFGR_BLV_SHIFT;
> -		adp8870_write(data->client, ADP8870_CFGR, reg_val);
> +		ret = adp8870_read(data->client, ADP8870_CFGR, &reg_val);
> +		if (!ret) {
> +			reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT);
> +			reg_val |= (val - 1) << CFGR_BLV_SHIFT;
> +			adp8870_write(data->client, ADP8870_CFGR, reg_val);
> +		}
>  		mutex_unlock(&data->lock);
>  	}
>  
> 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ