Skip to contentSkip to conversation

drivers/devfreq/devfreq.c:611 devfreq_update_interval() warn: inconsistent returns 'devfreq->lock'.

PATCH New Dan Carpenter 1 participant 1 message Jul 8, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 5/5 drivers/devfreq/devfreq.c:611 devfreq_update_interval() warn: inconsistent returns 'devfreq->lock'.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux.git devfreq-testing-timer
head:   20dcdf2e2493025a08aec1d2b11f0148b4810adb
commit: 20dcdf2e2493025a08aec1d2b11f0148b4810adb [5/5] PM / devfreq: Add governor flags to clarify the features
config: i386-randconfig-m021-20200707 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0

If you fix the issue, kindly add following tag as appropriate

New smatch warnings:
drivers/devfreq/devfreq.c:611 devfreq_update_interval() warn: inconsistent returns 'devfreq->lock'.

# https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux.git/commit/?id=20dcdf2e2493025a08aec1d2b11f0148b4810adb
git remote add chanwoo https://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/linux.git
git remote update chanwoo
git checkout 20dcdf2e2493025a08aec1d2b11f0148b4810adb
vim +611 drivers/devfreq/devfreq.c

3a1ec2e8d8a9f5 Chanwoo Choi     2020-01-29  573  void devfreq_update_interval(struct devfreq *devfreq, unsigned int *delay)
a3c98b8b2ede1f MyungJoo Ham     2011-10-02  574  {
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  575  	unsigned int cur_delay = devfreq->profile->polling_ms;
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  576  	unsigned int new_delay = *delay;
a3c98b8b2ede1f MyungJoo Ham     2011-10-02  577  
a3c98b8b2ede1f MyungJoo Ham     2011-10-02  578  	mutex_lock(&devfreq->lock);
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  579  	devfreq->profile->polling_ms = new_delay;
a3c98b8b2ede1f MyungJoo Ham     2011-10-02  580  
20dcdf2e249302 Chanwoo Choi     2020-07-03  581  	if (DEVFREQ_GOV_FLAG_IRQ_DRIVEN & devfreq->governor->flag)
20dcdf2e249302 Chanwoo Choi     2020-07-03  582  		return;

Need to unlock.

a3c98b8b2ede1f MyungJoo Ham     2011-10-02  583  
20dcdf2e249302 Chanwoo Choi     2020-07-03  584  	if (devfreq->stop_polling)
5c0f6c79595760 Dmitry Osipenko  2019-11-05  585  		goto out;
5c0f6c79595760 Dmitry Osipenko  2019-11-05  586  
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  587  	/* if new delay is zero, stop polling */
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  588  	if (!new_delay) {
a3c98b8b2ede1f MyungJoo Ham     2011-10-02  589  		mutex_unlock(&devfreq->lock);
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  590  		cancel_delayed_work_sync(&devfreq->work);
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  591  		return;
a3c98b8b2ede1f MyungJoo Ham     2011-10-02  592  	}
a3c98b8b2ede1f MyungJoo Ham     2011-10-02  593  
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  594  	/* if current delay is zero, start polling with new delay */
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  595  	if (!cur_delay) {
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  596  		queue_delayed_work(devfreq_wq, &devfreq->work,
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  597  			msecs_to_jiffies(devfreq->profile->polling_ms));
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  598  		goto out;
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  599  	}
a3c98b8b2ede1f MyungJoo Ham     2011-10-02  600  
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  601  	/* if current delay is greater than new delay, restart polling */
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  602  	if (cur_delay > new_delay) {
a3c98b8b2ede1f MyungJoo Ham     2011-10-02  603  		mutex_unlock(&devfreq->lock);
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  604  		cancel_delayed_work_sync(&devfreq->work);
a3c98b8b2ede1f MyungJoo Ham     2011-10-02  605  		mutex_lock(&devfreq->lock);
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  606  		if (!devfreq->stop_polling)
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  607  			queue_delayed_work(devfreq_wq, &devfreq->work,
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  608  				msecs_to_jiffies(devfreq->profile->polling_ms));
a3c98b8b2ede1f MyungJoo Ham     2011-10-02  609  	}
7e6fdd4bad033f Rajagopal Venkat 2012-10-26  610  out:

7e6fdd4bad033f Rajagopal Venkat 2012-10-26 @611 mutex_unlock(&devfreq->lock);
a3c98b8b2ede1f MyungJoo Ham 2011-10-02 612 }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org