Skip to contentSkip to conversation

kernel/sched/deadline.c:2548 find_later_rq() error: we previously assumed 'exec_ctx' could be null (see line 2541)

PATCH New Dan Carpenter 1 participant 1 message Jan 6, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 7230/7786 kernel/sched/deadline.c:2548 find_later_rq() error: we previously assumed 'exec_ctx' could be null (see line 2541)

tree:   https://android.googlesource.com/kernel/common android16-6.12
head:   0ad60853620e2bd7a2f165162fde4729cba0b46d
commit: a70dd213296b2f2524c2b4440cb60d46f85ab2e4 [7230/7786] ANDROID: sched: Add find_exec_ctx helper
config: i386-randconfig-141-20241221 (https://download.01.org/0day-ci/archive/20241222/[email protected]/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)

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/deadline.c:2548 find_later_rq() error: we previously assumed 'exec_ctx' could be null (see line 2541)

vim +/exec_ctx +2548 kernel/sched/deadline.c

eb7630f95f837d Connor O'Brien    2023-11-08  2530  static int find_later_rq(struct task_struct *sched_ctx, struct task_struct *exec_ctx)
1baca4ce16b8cc Juri Lelli        2013-11-07  2531  {
1baca4ce16b8cc Juri Lelli        2013-11-07  2532  	struct sched_domain *sd;
4ba2968420fa9d Christoph Lameter 2014-08-26  2533  	struct cpumask *later_mask = this_cpu_cpumask_var_ptr(local_cpu_mask_dl);
1baca4ce16b8cc Juri Lelli        2013-11-07  2534  	int this_cpu = smp_processor_id();
eb7630f95f837d Connor O'Brien    2023-11-08  2535  	int cpu = task_cpu(sched_ctx);
1baca4ce16b8cc Juri Lelli        2013-11-07  2536  
1baca4ce16b8cc Juri Lelli        2013-11-07  2537  	/* Make sure the mask is initialized first */
1baca4ce16b8cc Juri Lelli        2013-11-07  2538  	if (unlikely(!later_mask))
1baca4ce16b8cc Juri Lelli        2013-11-07  2539  		return -1;
1baca4ce16b8cc Juri Lelli        2013-11-07  2540  

a70dd213296b2f Connor O'Brien 2023-11-08 @2541 if (exec_ctx && exec_ctx->nr_cpus_allowed == 1)

This line assumes exec_ctx can be NULL.

1baca4ce16b8cc Juri Lelli        2013-11-07  2542  		return -1;
1baca4ce16b8cc Juri Lelli        2013-11-07  2543  
91ec6778ec4f96 Juri Lelli        2014-09-19  2544  	/*
91ec6778ec4f96 Juri Lelli        2014-09-19  2545  	 * We have to consider system topology and task affinity
97fb7a0a8944bd Ingo Molnar       2018-03-03  2546  	 * first, then we can look for a suitable CPU.
91ec6778ec4f96 Juri Lelli        2014-09-19  2547  	 */
eb7630f95f837d Connor O'Brien    2023-11-08 @2548  	if (!cpudl_find(&task_rq(exec_ctx)->rd->cpudl, sched_ctx, exec_ctx, later_mask))

But the next line dereferences it without checking for NULL

1baca4ce16b8cc Juri Lelli        2013-11-07  2549  		return -1;
1baca4ce16b8cc Juri Lelli        2013-11-07  2550  
1baca4ce16b8cc Juri Lelli        2013-11-07  2551  	/*
b18c3ca11c20ca Byungchul Park    2017-05-23  2552  	 * If we are here, some targets have been found, including
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki