All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-next:master 7385/14565] drivers/opp/core.c:2364 _opp_attach_genpd() warn: passing zero to 'PTR_ERR'
@ 2022-08-05 19:20 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2022-08-05 19:20 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 8200 bytes --]

BCC: lkp(a)intel.com
CC: kbuild-all(a)lists.01.org
CC: Linux Memory Management List <linux-mm@kvack.org>
TO: Viresh Kumar <viresh.kumar@linaro.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   e894659f149e779bc1b49016231d75994f6a29e9
commit: 442e7a1786e628b38175314ec1805966b8d0c02c [7385/14565] OPP: Migrate attach-genpd API to use set-config helpers
:::::: branch date: 4 hours ago
:::::: commit date: 4 weeks ago
config: i386-randconfig-m021 (https://download.01.org/0day-ci/archive/20220806/202208060312.GvvAge8e-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0

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

New smatch warnings:
drivers/opp/core.c:2364 _opp_attach_genpd() warn: passing zero to 'PTR_ERR'

Old smatch warnings:
drivers/opp/core.c:1278 dev_pm_opp_set_rate() warn: passing a valid pointer to 'PTR_ERR'
drivers/opp/core.c:2795 _opp_set_availability() warn: passing a valid pointer to 'PTR_ERR'
drivers/opp/core.c:2866 dev_pm_opp_adjust_voltage() warn: passing a valid pointer to 'PTR_ERR'

vim +/PTR_ERR +2364 drivers/opp/core.c

6319aee10e5303 Viresh Kumar    2019-05-08  2306  
4f018bc0e1cfde Viresh Kumar    2018-06-26  2307  /**
442e7a1786e628 Viresh Kumar    2022-05-26  2308   * _opp_attach_genpd - Attach genpd(s) for the device and save virtual device pointer
6319aee10e5303 Viresh Kumar    2019-05-08  2309   * @dev: Consumer device for which the genpd is getting attached.
6319aee10e5303 Viresh Kumar    2019-05-08  2310   * @names: Null terminated array of pointers containing names of genpd to attach.
17a8f868ae3e85 Viresh Kumar    2019-07-08  2311   * @virt_devs: Pointer to return the array of virtual devices.
4f018bc0e1cfde Viresh Kumar    2018-06-26  2312   *
4f018bc0e1cfde Viresh Kumar    2018-06-26  2313   * Multiple generic power domains for a device are supported with the help of
4f018bc0e1cfde Viresh Kumar    2018-06-26  2314   * virtual genpd devices, which are created for each consumer device - genpd
4f018bc0e1cfde Viresh Kumar    2018-06-26  2315   * pair. These are the device structures which are attached to the power domain
4f018bc0e1cfde Viresh Kumar    2018-06-26  2316   * and are required by the OPP core to set the performance state of the genpd.
6319aee10e5303 Viresh Kumar    2019-05-08  2317   * The same API also works for the case where single genpd is available and so
6319aee10e5303 Viresh Kumar    2019-05-08  2318   * we don't need to support that separately.
4f018bc0e1cfde Viresh Kumar    2018-06-26  2319   *
4f018bc0e1cfde Viresh Kumar    2018-06-26  2320   * This helper will normally be called by the consumer driver of the device
6319aee10e5303 Viresh Kumar    2019-05-08  2321   * "dev", as only that has details of the genpd names.
4f018bc0e1cfde Viresh Kumar    2018-06-26  2322   *
6319aee10e5303 Viresh Kumar    2019-05-08  2323   * This helper needs to be called once with a list of all genpd to attach.
6319aee10e5303 Viresh Kumar    2019-05-08  2324   * Otherwise the original device structure will be used instead by the OPP core.
baea35e4db17a7 Viresh Kumar    2019-07-17  2325   *
baea35e4db17a7 Viresh Kumar    2019-07-17  2326   * The order of entries in the names array must match the order in which
baea35e4db17a7 Viresh Kumar    2019-07-17  2327   * "required-opps" are added in DT.
4f018bc0e1cfde Viresh Kumar    2018-06-26  2328   */
442e7a1786e628 Viresh Kumar    2022-05-26  2329  static int _opp_attach_genpd(struct opp_table *opp_table, struct device *dev,
3734b9f2cee01d Dmitry Osipenko 2021-09-27  2330  			const char * const *names, struct device ***virt_devs)
4f018bc0e1cfde Viresh Kumar    2018-06-26  2331  {
6319aee10e5303 Viresh Kumar    2019-05-08  2332  	struct device *virt_dev;
baea35e4db17a7 Viresh Kumar    2019-07-17  2333  	int index = 0, ret = -EINVAL;
3734b9f2cee01d Dmitry Osipenko 2021-09-27  2334  	const char * const *name = names;
4f018bc0e1cfde Viresh Kumar    2018-06-26  2335  
cb60e9602cce15 Viresh Kumar    2020-08-31  2336  	if (opp_table->genpd_virt_devs)
442e7a1786e628 Viresh Kumar    2022-05-26  2337  		return 0;
4f018bc0e1cfde Viresh Kumar    2018-06-26  2338  
6319aee10e5303 Viresh Kumar    2019-05-08  2339  	/*
6319aee10e5303 Viresh Kumar    2019-05-08  2340  	 * If the genpd's OPP table isn't already initialized, parsing of the
6319aee10e5303 Viresh Kumar    2019-05-08  2341  	 * required-opps fail for dev. We should retry this after genpd's OPP
6319aee10e5303 Viresh Kumar    2019-05-08  2342  	 * table is added.
6319aee10e5303 Viresh Kumar    2019-05-08  2343  	 */
442e7a1786e628 Viresh Kumar    2022-05-26  2344  	if (!opp_table->required_opp_count)
442e7a1786e628 Viresh Kumar    2022-05-26  2345  		return -EPROBE_DEFER;
6319aee10e5303 Viresh Kumar    2019-05-08  2346  
4f018bc0e1cfde Viresh Kumar    2018-06-26  2347  	mutex_lock(&opp_table->genpd_virt_dev_lock);
4f018bc0e1cfde Viresh Kumar    2018-06-26  2348  
c0ab9e0812da8e Viresh Kumar    2019-05-08  2349  	opp_table->genpd_virt_devs = kcalloc(opp_table->required_opp_count,
c0ab9e0812da8e Viresh Kumar    2019-05-08  2350  					     sizeof(*opp_table->genpd_virt_devs),
c0ab9e0812da8e Viresh Kumar    2019-05-08  2351  					     GFP_KERNEL);
c0ab9e0812da8e Viresh Kumar    2019-05-08  2352  	if (!opp_table->genpd_virt_devs)
c0ab9e0812da8e Viresh Kumar    2019-05-08  2353  		goto unlock;
4f018bc0e1cfde Viresh Kumar    2018-06-26  2354  
6319aee10e5303 Viresh Kumar    2019-05-08  2355  	while (*name) {
6319aee10e5303 Viresh Kumar    2019-05-08  2356  		if (index >= opp_table->required_opp_count) {
6319aee10e5303 Viresh Kumar    2019-05-08  2357  			dev_err(dev, "Index can't be greater than required-opp-count - 1, %s (%d : %d)\n",
6319aee10e5303 Viresh Kumar    2019-05-08  2358  				*name, opp_table->required_opp_count, index);
6319aee10e5303 Viresh Kumar    2019-05-08  2359  			goto err;
6319aee10e5303 Viresh Kumar    2019-05-08  2360  		}
4f018bc0e1cfde Viresh Kumar    2018-06-26  2361  
6319aee10e5303 Viresh Kumar    2019-05-08  2362  		virt_dev = dev_pm_domain_attach_by_name(dev, *name);
4ea9496cbc959e Tang Bin        2022-05-24  2363  		if (IS_ERR_OR_NULL(virt_dev)) {
4ea9496cbc959e Tang Bin        2022-05-24 @2364  			ret = PTR_ERR(virt_dev) ? : -ENODEV;
6319aee10e5303 Viresh Kumar    2019-05-08  2365  			dev_err(dev, "Couldn't attach to pm_domain: %d\n", ret);
6319aee10e5303 Viresh Kumar    2019-05-08  2366  			goto err;
4f018bc0e1cfde Viresh Kumar    2018-06-26  2367  		}
4f018bc0e1cfde Viresh Kumar    2018-06-26  2368  
4f018bc0e1cfde Viresh Kumar    2018-06-26  2369  		opp_table->genpd_virt_devs[index] = virt_dev;
baea35e4db17a7 Viresh Kumar    2019-07-17  2370  		index++;
6319aee10e5303 Viresh Kumar    2019-05-08  2371  		name++;
6319aee10e5303 Viresh Kumar    2019-05-08  2372  	}
6319aee10e5303 Viresh Kumar    2019-05-08  2373  
17a8f868ae3e85 Viresh Kumar    2019-07-08  2374  	if (virt_devs)
17a8f868ae3e85 Viresh Kumar    2019-07-08  2375  		*virt_devs = opp_table->genpd_virt_devs;
4f018bc0e1cfde Viresh Kumar    2018-06-26  2376  	mutex_unlock(&opp_table->genpd_virt_dev_lock);
4f018bc0e1cfde Viresh Kumar    2018-06-26  2377  
442e7a1786e628 Viresh Kumar    2022-05-26  2378  	return 0;
6319aee10e5303 Viresh Kumar    2019-05-08  2379  
6319aee10e5303 Viresh Kumar    2019-05-08  2380  err:
442e7a1786e628 Viresh Kumar    2022-05-26  2381  	_detach_genpd(opp_table);
c0ab9e0812da8e Viresh Kumar    2019-05-08  2382  unlock:
6319aee10e5303 Viresh Kumar    2019-05-08  2383  	mutex_unlock(&opp_table->genpd_virt_dev_lock);
442e7a1786e628 Viresh Kumar    2022-05-26  2384  	return ret;
6319aee10e5303 Viresh Kumar    2019-05-08  2385  

:::::: The code at line 2364 was first introduced by commit
:::::: 4ea9496cbc959eb5c78f3e379199aca9ef4e386b opp: Fix error check in dev_pm_opp_attach_genpd()

:::::: TO: Tang Bin <tangbin@cmss.chinamobile.com>
:::::: CC: Viresh Kumar <viresh.kumar@linaro.org>

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-05 19:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-05 19:20 [linux-next:master 7385/14565] drivers/opp/core.c:2364 _opp_attach_genpd() warn: passing zero to 'PTR_ERR' kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.