[PATCH v3 4/4] leds: pca955x: Add HW blink support

Dan Carpenter dan.carpenter at oracle.com
Tue Apr 12 21:33:30 AEST 2022


Hi Eddie,

url:    https://github.com/intel-lab-lkp/linux/commits/Eddie-James/leds-pca955x-Add-HW-blink-support/20220412-002330
base:   git://git.kernel.org/pub/scm/linux/kernel/git/pavel/linux-leds.git for-next
config: i386-randconfig-m021-20220411 (https://download.01.org/0day-ci/archive/20220412/202204121953.zHZcX6EV-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.2.0-19) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>
Reported-by: Dan Carpenter <dan.carpenter at oracle.com>

smatch warnings:
drivers/leds/leds-pca955x.c:455 pca955x_led_blink() error: uninitialized symbol 'ret'.

vim +/ret +455 drivers/leds/leds-pca955x.c

3b7b1899f6cc6d Eddie James      2022-04-11  390  static int pca955x_led_blink(struct led_classdev *led_cdev,
3b7b1899f6cc6d Eddie James      2022-04-11  391  			     unsigned long *delay_on, unsigned long *delay_off)
3b7b1899f6cc6d Eddie James      2022-04-11  392  {
3b7b1899f6cc6d Eddie James      2022-04-11  393  	struct pca955x_led *pca955x_led = led_to_pca955x(led_cdev);
3b7b1899f6cc6d Eddie James      2022-04-11  394  	struct pca955x *pca955x = pca955x_led->pca955x;
3b7b1899f6cc6d Eddie James      2022-04-11  395  	unsigned long p = *delay_on + *delay_off;
3b7b1899f6cc6d Eddie James      2022-04-11  396  	int ret;
3b7b1899f6cc6d Eddie James      2022-04-11  397  
3b7b1899f6cc6d Eddie James      2022-04-11  398  	mutex_lock(&pca955x->lock);
3b7b1899f6cc6d Eddie James      2022-04-11  399  
3b7b1899f6cc6d Eddie James      2022-04-11  400  	if (p) {
3b7b1899f6cc6d Eddie James      2022-04-11  401  		if (*delay_on != *delay_off) {
3b7b1899f6cc6d Eddie James      2022-04-11  402  			ret = -EINVAL;
3b7b1899f6cc6d Eddie James      2022-04-11  403  			goto out;
3b7b1899f6cc6d Eddie James      2022-04-11  404  		}
3b7b1899f6cc6d Eddie James      2022-04-11  405  
3b7b1899f6cc6d Eddie James      2022-04-11  406  		if (p < pca955x_psc_to_period(pca955x, 0) ||
3b7b1899f6cc6d Eddie James      2022-04-11  407  		    p > pca955x_psc_to_period(pca955x, 0xff)) {
3b7b1899f6cc6d Eddie James      2022-04-11  408  			ret = -EINVAL;
3b7b1899f6cc6d Eddie James      2022-04-11  409  			goto out;
3b7b1899f6cc6d Eddie James      2022-04-11  410  		}
3b7b1899f6cc6d Eddie James      2022-04-11  411  	} else {
3b7b1899f6cc6d Eddie James      2022-04-11  412  		p = pca955x->active_blink ? pca955x->blink_period :
3b7b1899f6cc6d Eddie James      2022-04-11  413  			PCA955X_BLINK_DEFAULT_MS;
3b7b1899f6cc6d Eddie James      2022-04-11  414  	}
3b7b1899f6cc6d Eddie James      2022-04-11  415  
3b7b1899f6cc6d Eddie James      2022-04-11  416  	if (!pca955x->active_blink ||
3b7b1899f6cc6d Eddie James      2022-04-11  417  	    pca955x->active_blink == BIT(pca955x_led->led_num) ||
3b7b1899f6cc6d Eddie James      2022-04-11  418  	    pca955x->blink_period == p) {
3b7b1899f6cc6d Eddie James      2022-04-11  419  		u8 psc = pca955x_period_to_psc(pca955x, p);
f46e9203d9a100 Nate Case        2008-07-16  420  
3b7b1899f6cc6d Eddie James      2022-04-11  421  		if (!test_and_set_bit(pca955x_led->led_num,
3b7b1899f6cc6d Eddie James      2022-04-11  422  				      &pca955x->active_blink)) {
3b7b1899f6cc6d Eddie James      2022-04-11  423  			u8 ls;
3b7b1899f6cc6d Eddie James      2022-04-11  424  			int reg = pca955x_led->led_num / 4;
3b7b1899f6cc6d Eddie James      2022-04-11  425  			int bit = pca955x_led->led_num % 4;
3b7b1899f6cc6d Eddie James      2022-04-11  426  
3b7b1899f6cc6d Eddie James      2022-04-11  427  			ret = pca955x_read_ls(pca955x, reg, &ls);
3b7b1899f6cc6d Eddie James      2022-04-11  428  			if (ret)
3b7b1899f6cc6d Eddie James      2022-04-11  429  				goto out;
3b7b1899f6cc6d Eddie James      2022-04-11  430  
3b7b1899f6cc6d Eddie James      2022-04-11  431  			ls = pca955x_ledsel(ls, bit, PCA955X_LS_BLINK0);
9e58c2a7bb91f6 Eddie James      2022-04-11  432  			ret = pca955x_write_ls(pca955x, reg, ls);
3b7b1899f6cc6d Eddie James      2022-04-11  433  			if (ret)
3b7b1899f6cc6d Eddie James      2022-04-11  434  				goto out;
3b7b1899f6cc6d Eddie James      2022-04-11  435  		}
3b7b1899f6cc6d Eddie James      2022-04-11  436  
3b7b1899f6cc6d Eddie James      2022-04-11  437  		if (pca955x->blink_period != p) {
3b7b1899f6cc6d Eddie James      2022-04-11  438  			pca955x->blink_period = p;
3b7b1899f6cc6d Eddie James      2022-04-11  439  			ret = pca955x_write_psc(pca955x, 0, psc);
3b7b1899f6cc6d Eddie James      2022-04-11  440  			if (ret)
3b7b1899f6cc6d Eddie James      2022-04-11  441  				goto out;
3b7b1899f6cc6d Eddie James      2022-04-11  442  		}

Can both the !test_and_set_bit() and pca955x->blink_period != p conditions
be false?  If so then "ret" is uninitialized.

3b7b1899f6cc6d Eddie James      2022-04-11  443  
3b7b1899f6cc6d Eddie James      2022-04-11  444  		p = pca955x_psc_to_period(pca955x, psc);
3b7b1899f6cc6d Eddie James      2022-04-11  445  		p /= 2;
3b7b1899f6cc6d Eddie James      2022-04-11  446  		*delay_on = p;
3b7b1899f6cc6d Eddie James      2022-04-11  447  		*delay_off = p;
3b7b1899f6cc6d Eddie James      2022-04-11  448  	} else {
3b7b1899f6cc6d Eddie James      2022-04-11  449  		ret = -EBUSY;
3b7b1899f6cc6d Eddie James      2022-04-11  450  	}
e7e11d8ba807d4 Alexander Stein  2012-05-29  451  
1591caf2d5eafd Cédric Le Goater 2017-08-30  452  out:
e7e11d8ba807d4 Alexander Stein  2012-05-29  453  	mutex_unlock(&pca955x->lock);
f46e9203d9a100 Nate Case        2008-07-16  454  
1591caf2d5eafd Cédric Le Goater 2017-08-30 @455  	return ret;
f46e9203d9a100 Nate Case        2008-07-16  456  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp



More information about the openbmc mailing list