Skip to contentSkip to conversation

kernel/sched/ext.c:5332 scx_alloc_and_add_sched() warn: passing zero to 'ERR_PTR'

DISCUSSION kernel test robot 1 participant 1 message Dec 14, 2025

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Tejun Heo <[email protected]>
CC: Andrea Righi <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   8f0b4cce4481fb22653697cced8d0d04027cb1e8
commit: c201ea1578d3b9eed29494ba3dc2abbccf62c4c8 sched_ext: Move event_stats_cpu into scx_sched
date:   8 months ago

:::::: branch date: 4 hours ago
:::::: commit date: 8 months ago
config: powerpc64-randconfig-r073-20251213 (https://download.01.org/0day-ci/archive/20251214/[email protected]/config)
compiler: powerpc64-linux-gcc (GCC) 13.4.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
kernel/sched/ext.c:5332 scx_alloc_and_add_sched() warn: passing zero to 'ERR_PTR'

vim +/ERR_PTR +5332 kernel/sched/ext.c

f0e1a0643a59bf1 Tejun Heo 2024-06-18  5265  
d9f754631021802 Tejun Heo 2025-04-29  5266  static struct scx_sched *scx_alloc_and_add_sched(struct sched_ext_ops *ops)
d9f754631021802 Tejun Heo 2025-04-29  5267  {
d9f754631021802 Tejun Heo 2025-04-29  5268  	struct scx_sched *sch;
8409b800a0b1f14 Tejun Heo 2025-04-29  5269  	int node, ret;
d9f754631021802 Tejun Heo 2025-04-29  5270  
d9f754631021802 Tejun Heo 2025-04-29  5271  	sch = kzalloc(sizeof(*sch), GFP_KERNEL);
d9f754631021802 Tejun Heo 2025-04-29  5272  	if (!sch)
d9f754631021802 Tejun Heo 2025-04-29  5273  		return ERR_PTR(-ENOMEM);
d9f754631021802 Tejun Heo 2025-04-29  5274  
d9f754631021802 Tejun Heo 2025-04-29  5275  	sch->exit_info = alloc_exit_info(ops->exit_dump_len);
d9f754631021802 Tejun Heo 2025-04-29  5276  	if (!sch->exit_info) {
d9f754631021802 Tejun Heo 2025-04-29  5277  		ret = -ENOMEM;
d9f754631021802 Tejun Heo 2025-04-29  5278  		goto err_free_sch;
d9f754631021802 Tejun Heo 2025-04-29  5279  	}
d9f754631021802 Tejun Heo 2025-04-29  5280  
cdf5a6faa8cf0ef Tejun Heo 2025-04-29  5281  	ret = rhashtable_init(&sch->dsq_hash, &dsq_hash_params);
cdf5a6faa8cf0ef Tejun Heo 2025-04-29  5282  	if (ret < 0)
cdf5a6faa8cf0ef Tejun Heo 2025-04-29  5283  		goto err_free_ei;
cdf5a6faa8cf0ef Tejun Heo 2025-04-29  5284  
8409b800a0b1f14 Tejun Heo 2025-04-29  5285  	sch->global_dsqs = kcalloc(nr_node_ids, sizeof(sch->global_dsqs[0]),
8409b800a0b1f14 Tejun Heo 2025-04-29  5286  				   GFP_KERNEL);
8409b800a0b1f14 Tejun Heo 2025-04-29  5287  	if (!sch->global_dsqs) {
8409b800a0b1f14 Tejun Heo 2025-04-29  5288  		ret = -ENOMEM;
8409b800a0b1f14 Tejun Heo 2025-04-29  5289  		goto err_free_hash;
8409b800a0b1f14 Tejun Heo 2025-04-29  5290  	}
8409b800a0b1f14 Tejun Heo 2025-04-29  5291  
8409b800a0b1f14 Tejun Heo 2025-04-29  5292  	for_each_node_state(node, N_POSSIBLE) {
8409b800a0b1f14 Tejun Heo 2025-04-29  5293  		struct scx_dispatch_q *dsq;
8409b800a0b1f14 Tejun Heo 2025-04-29  5294  
8409b800a0b1f14 Tejun Heo 2025-04-29  5295  		dsq = kzalloc_node(sizeof(*dsq), GFP_KERNEL, node);
8409b800a0b1f14 Tejun Heo 2025-04-29  5296  		if (!dsq) {
8409b800a0b1f14 Tejun Heo 2025-04-29  5297  			ret = -ENOMEM;
8409b800a0b1f14 Tejun Heo 2025-04-29  5298  			goto err_free_gdsqs;
8409b800a0b1f14 Tejun Heo 2025-04-29  5299  		}
8409b800a0b1f14 Tejun Heo 2025-04-29  5300  
8409b800a0b1f14 Tejun Heo 2025-04-29  5301  		init_dsq(dsq, SCX_DSQ_GLOBAL);
8409b800a0b1f14 Tejun Heo 2025-04-29  5302  		sch->global_dsqs[node] = dsq;
8409b800a0b1f14 Tejun Heo 2025-04-29  5303  	}
8409b800a0b1f14 Tejun Heo 2025-04-29  5304  
c201ea1578d3b9e Tejun Heo 2025-04-29  5305  	sch->event_stats_cpu = alloc_percpu(struct scx_event_stats);
c201ea1578d3b9e Tejun Heo 2025-04-29  5306  	if (!sch->event_stats_cpu)
c201ea1578d3b9e Tejun Heo 2025-04-29  5307  		goto err_free_gdsqs;
c201ea1578d3b9e Tejun Heo 2025-04-29  5308  
d9f754631021802 Tejun Heo 2025-04-29  5309  	atomic_set(&sch->exit_kind, SCX_EXIT_NONE);
d9f754631021802 Tejun Heo 2025-04-29  5310  	sch->ops = *ops;
d9f754631021802 Tejun Heo 2025-04-29  5311  	ops->priv = sch;
d9f754631021802 Tejun Heo 2025-04-29  5312  
d9f754631021802 Tejun Heo 2025-04-29  5313  	sch->kobj.kset = scx_kset;
d9f754631021802 Tejun Heo 2025-04-29  5314  	ret = kobject_init_and_add(&sch->kobj, &scx_ktype, NULL, "root");
d9f754631021802 Tejun Heo 2025-04-29  5315  	if (ret < 0)
c201ea1578d3b9e Tejun Heo 2025-04-29  5316  		goto err_free_event_stats;
d9f754631021802 Tejun Heo 2025-04-29  5317  
d9f754631021802 Tejun Heo 2025-04-29  5318  	return sch;
d9f754631021802 Tejun Heo 2025-04-29  5319  
c201ea1578d3b9e Tejun Heo 2025-04-29  5320  err_free_event_stats:
c201ea1578d3b9e Tejun Heo 2025-04-29  5321  	free_percpu(sch->event_stats_cpu);
8409b800a0b1f14 Tejun Heo 2025-04-29  5322  err_free_gdsqs:
8409b800a0b1f14 Tejun Heo 2025-04-29  5323  	for_each_node_state(node, N_POSSIBLE)
8409b800a0b1f14 Tejun Heo 2025-04-29  5324  		kfree(sch->global_dsqs[node]);
8409b800a0b1f14 Tejun Heo 2025-04-29  5325  	kfree(sch->global_dsqs);
cdf5a6faa8cf0ef Tejun Heo 2025-04-29  5326  err_free_hash:
cdf5a6faa8cf0ef Tejun Heo 2025-04-29  5327  	rhashtable_free_and_destroy(&sch->dsq_hash, NULL, NULL);
d9f754631021802 Tejun Heo 2025-04-29  5328  err_free_ei:
d9f754631021802 Tejun Heo 2025-04-29  5329  	free_exit_info(sch->exit_info);
d9f754631021802 Tejun Heo 2025-04-29  5330  err_free_sch:
d9f754631021802 Tejun Heo 2025-04-29  5331  	kfree(sch);

d9f754631021802 Tejun Heo 2025-04-29 @5332 return ERR_PTR(ret);
d9f754631021802 Tejun Heo 2025-04-29 5333 }
d9f754631021802 Tejun Heo 2025-04-29 5334

:::::: The code at line 5332 was first introduced by commit
:::::: d9f754631021802b3bd3f58781b4c8ff3677b3a8 sched_ext: Factor out scx_alloc_and_add_sched()

:::::: TO: Tejun Heo <[email protected]>
:::::: CC: Tejun Heo <[email protected]>

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki