Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

backlight: adp8860: Fix another uninitialized variable use

A recent patch I did fixed two potential uses of uninitialized
variables in the adp8870 and adp8860 drivers. Unfortunately,
I missed another one:

drivers/video/backlight/adp8860_bl.c: In function 'adp8860_bl_ambient_light_level_show':
drivers/video/backlight/adp8860_bl.c:570:11: warning: 'reg_val' may be used uninitialized in this function

This does the same change as before in one additional function,
and also changes the check for the return value in a way that
avoids another false positive warning with a similar message.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 6be3a5a9cd91 ("backlight: adp88x0: Fix uninitialized variable use")
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Arnd Bergmann and committed by
Lee Jones
02f22c00 2f4647a1

+5 -3
+5 -3
drivers/video/backlight/adp8860_bl.c
··· 566 566 567 567 mutex_lock(&data->lock); 568 568 error = adp8860_read(data->client, ADP8860_PH1LEVL, &reg_val); 569 - ret_val = reg_val; 570 - error |= adp8860_read(data->client, ADP8860_PH1LEVH, &reg_val); 569 + if (!error) { 570 + ret_val = reg_val; 571 + error = adp8860_read(data->client, ADP8860_PH1LEVH, &reg_val); 572 + } 571 573 mutex_unlock(&data->lock); 572 574 573 - if (error < 0) 575 + if (error) 574 576 return error; 575 577 576 578 /* Return 13-bit conversion value for the first light sensor */