[linux-next:master 3781/5053] drivers/thermal/devfreq_cooling.c:433 of_devfreq_cooling_register_power() warn: passing zero to 'ERR_PTR'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   fa903833ae344e4f4d798a8b85ba3ef0c5ce96c9
commit: f8d354e821b268c23a6cd548b7154e55c3954496 [3781/5053] thermal/drivers/devfreq_cooling: Use device name instead of auto-numbering
config: i386-randconfig-m021-20210317 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

smatch warnings:
drivers/thermal/devfreq_cooling.c:433 of_devfreq_cooling_register_power() warn: passing zero to 'ERR_PTR'

vim +/ERR_PTR +433 drivers/thermal/devfreq_cooling.c

3c99c2cef75eb5 Javi Merino       2015-11-02  354  struct thermal_cooling_device *
a76caf55e5b356 Ørjan Eide        2015-09-10  355  of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
a76caf55e5b356 Ørjan Eide        2015-09-10  356  				  struct devfreq_cooling_power *dfc_power)
a76caf55e5b356 Ørjan Eide        2015-09-10  357  {
a76caf55e5b356 Ørjan Eide        2015-09-10  358  	struct thermal_cooling_device *cdev;
615510fe13bd24 Lukasz Luba       2020-12-10  359  	struct device *dev = df->dev.parent;
a76caf55e5b356 Ørjan Eide        2015-09-10  360  	struct devfreq_cooling_device *dfc;
f8d354e821b268 Daniel Lezcano    2021-03-14  361  	char *name;
615510fe13bd24 Lukasz Luba       2020-12-10  362  	int err, num_opps;
a76caf55e5b356 Ørjan Eide        2015-09-10  363  
a76caf55e5b356 Ørjan Eide        2015-09-10  364  	dfc = kzalloc(sizeof(*dfc), GFP_KERNEL);
a76caf55e5b356 Ørjan Eide        2015-09-10  365  	if (!dfc)
a76caf55e5b356 Ørjan Eide        2015-09-10  366  		return ERR_PTR(-ENOMEM);
a76caf55e5b356 Ørjan Eide        2015-09-10  367  
a76caf55e5b356 Ørjan Eide        2015-09-10  368  	dfc->devfreq = df;
a76caf55e5b356 Ørjan Eide        2015-09-10  369  
4401117bf7fc11 Lukasz Luba       2020-12-15  370  	dfc->em_pd = em_pd_get(dev);
4401117bf7fc11 Lukasz Luba       2020-12-15  371  	if (dfc->em_pd) {
a76caf55e5b356 Ørjan Eide        2015-09-10  372  		devfreq_cooling_ops.get_requested_power =
a76caf55e5b356 Ørjan Eide        2015-09-10  373  			devfreq_cooling_get_requested_power;
a76caf55e5b356 Ørjan Eide        2015-09-10  374  		devfreq_cooling_ops.state2power = devfreq_cooling_state2power;
a76caf55e5b356 Ørjan Eide        2015-09-10  375  		devfreq_cooling_ops.power2state = devfreq_cooling_power2state;
a76caf55e5b356 Ørjan Eide        2015-09-10  376  
615510fe13bd24 Lukasz Luba       2020-12-10  377  		dfc->power_ops = dfc_power;
615510fe13bd24 Lukasz Luba       2020-12-10  378  
4401117bf7fc11 Lukasz Luba       2020-12-15  379  		num_opps = em_pd_nr_perf_states(dfc->em_pd);
615510fe13bd24 Lukasz Luba       2020-12-10  380  	} else {
615510fe13bd24 Lukasz Luba       2020-12-10  381  		/* Backward compatibility for drivers which do not use IPA */
615510fe13bd24 Lukasz Luba       2020-12-10  382  		dev_dbg(dev, "missing EM for cooling device\n");
615510fe13bd24 Lukasz Luba       2020-12-10  383  
615510fe13bd24 Lukasz Luba       2020-12-10  384  		num_opps = dev_pm_opp_get_opp_count(dev);
615510fe13bd24 Lukasz Luba       2020-12-10  385  
615510fe13bd24 Lukasz Luba       2020-12-10  386  		err = devfreq_cooling_gen_tables(dfc, num_opps);
a76caf55e5b356 Ørjan Eide        2015-09-10  387  		if (err)
a76caf55e5b356 Ørjan Eide        2015-09-10  388  			goto free_dfc;
615510fe13bd24 Lukasz Luba       2020-12-10  389  	}
615510fe13bd24 Lukasz Luba       2020-12-10  390  
615510fe13bd24 Lukasz Luba       2020-12-10  391  	if (num_opps <= 0) {
615510fe13bd24 Lukasz Luba       2020-12-10  392  		err = -EINVAL;
615510fe13bd24 Lukasz Luba       2020-12-10  393  		goto free_dfc;
615510fe13bd24 Lukasz Luba       2020-12-10  394  	}
a76caf55e5b356 Ørjan Eide        2015-09-10  395  
615510fe13bd24 Lukasz Luba       2020-12-10  396  	/* max_state is an index, not a counter */
615510fe13bd24 Lukasz Luba       2020-12-10  397  	dfc->max_state = num_opps - 1;
615510fe13bd24 Lukasz Luba       2020-12-10  398  
615510fe13bd24 Lukasz Luba       2020-12-10  399  	err = dev_pm_qos_add_request(dev, &dfc->req_max_freq,
04fa9c804b0ed5 Matthias Kaehlcke 2020-03-18  400  				     DEV_PM_QOS_MAX_FREQUENCY,
04fa9c804b0ed5 Matthias Kaehlcke 2020-03-18  401  				     PM_QOS_MAX_FREQUENCY_DEFAULT_VALUE);
2f96c035fbd143 Matthew Wilcox    2016-12-21  402  	if (err < 0)
615510fe13bd24 Lukasz Luba       2020-12-10  403  		goto free_table;
04fa9c804b0ed5 Matthias Kaehlcke 2020-03-18  404  
f8d354e821b268 Daniel Lezcano    2021-03-14  405  	cdev = ERR_PTR(-ENOMEM);

This should be "err = -ENOMEM;"

f8d354e821b268 Daniel Lezcano    2021-03-14  406  	name = kasprintf(GFP_KERNEL, "devfreq-%s", dev_name(dev));
f8d354e821b268 Daniel Lezcano    2021-03-14  407  	if (!name)
04fa9c804b0ed5 Matthias Kaehlcke 2020-03-18  408  		goto remove_qos_req;
615510fe13bd24 Lukasz Luba       2020-12-10  409  
f8d354e821b268 Daniel Lezcano    2021-03-14  410  	cdev = thermal_of_cooling_device_register(np, name, dfc,
a76caf55e5b356 Ørjan Eide        2015-09-10  411  						  &devfreq_cooling_ops);
f8d354e821b268 Daniel Lezcano    2021-03-14  412  	kfree(name);
f8d354e821b268 Daniel Lezcano    2021-03-14  413  
a76caf55e5b356 Ørjan Eide        2015-09-10  414  	if (IS_ERR(cdev)) {
a76caf55e5b356 Ørjan Eide        2015-09-10  415  		err = PTR_ERR(cdev);
615510fe13bd24 Lukasz Luba       2020-12-10  416  		dev_err(dev,
a76caf55e5b356 Ørjan Eide        2015-09-10  417  			"Failed to register devfreq cooling device (%d)\n",
a76caf55e5b356 Ørjan Eide        2015-09-10  418  			err);
f8d354e821b268 Daniel Lezcano    2021-03-14  419  		goto remove_qos_req;
a76caf55e5b356 Ørjan Eide        2015-09-10  420  	}
a76caf55e5b356 Ørjan Eide        2015-09-10  421  
a76caf55e5b356 Ørjan Eide        2015-09-10  422  	dfc->cdev = cdev;
a76caf55e5b356 Ørjan Eide        2015-09-10  423  
3c99c2cef75eb5 Javi Merino       2015-11-02  424  	return cdev;
a76caf55e5b356 Ørjan Eide        2015-09-10  425  
04fa9c804b0ed5 Matthias Kaehlcke 2020-03-18  426  remove_qos_req:
04fa9c804b0ed5 Matthias Kaehlcke 2020-03-18  427  	dev_pm_qos_remove_request(&dfc->req_max_freq);
615510fe13bd24 Lukasz Luba       2020-12-10  428  free_table:
a76caf55e5b356 Ørjan Eide        2015-09-10  429  	kfree(dfc->freq_table);
a76caf55e5b356 Ørjan Eide        2015-09-10  430  free_dfc:
a76caf55e5b356 Ørjan Eide        2015-09-10  431  	kfree(dfc);
a76caf55e5b356 Ørjan Eide        2015-09-10  432  
a76caf55e5b356 Ørjan Eide        2015-09-10 @433  	return ERR_PTR(err);
a76caf55e5b356 Ørjan Eide        2015-09-10  434  }

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

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux