[drm-intel:for-linux-next-gt 1/4] drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2680 guc_context_policy_init_v70() warn: variable dereferenced before check 'ce' (see line 2663)
Dan Carpenter
dan.carpenter at linaro.org
Mon Mar 11 05:29:25 UTC 2024
tree: git://anongit.freedesktop.org/drm-intel for-linux-next-gt
head: 7ad6a8fae597af7fae5193efc73276609337c360
commit: cec82816d0d018f178b9b7f88fe4bf80d66954e9 [1/4] drm/i915/guc: Use context hints for GT frequency
config: i386-randconfig-141-20240309 (https://download.01.org/0day-ci/archive/20240310/202403101225.7AheJhZJ-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.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 <lkp at intel.com>
| Reported-by: Dan Carpenter <dan.carpenter at linaro.org>
| Closes: https://lore.kernel.org/r/202403101225.7AheJhZJ-lkp@intel.com/
New smatch warnings:
drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c:2680 guc_context_policy_init_v70() warn: variable dereferenced before check 'ce' (see line 2663)
vim +/ce +2680 drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
774ce1510e6ccb Daniele Ceraolo Spurio 2022-07-18 2661 static int guc_context_policy_init_v70(struct intel_context *ce, bool loop)
2584b3549f4c40 John Harrison 2022-04-12 2662 {
2584b3549f4c40 John Harrison 2022-04-12 @2663 struct intel_engine_cs *engine = ce->engine;
^^^^^^^^^^
Unchecked dereference
3f2f20da79b208 Andi Shyti 2023-12-29 2664 struct intel_guc *guc = gt_to_guc(engine->gt);
2584b3549f4c40 John Harrison 2022-04-12 2665 struct context_policy policy;
2584b3549f4c40 John Harrison 2022-04-12 2666 u32 execution_quantum;
2584b3549f4c40 John Harrison 2022-04-12 2667 u32 preemption_timeout;
cec82816d0d018 Vinay Belgaumkar 2024-03-05 2668 u32 slpc_ctx_freq_req = 0;
2584b3549f4c40 John Harrison 2022-04-12 2669 unsigned long flags;
2584b3549f4c40 John Harrison 2022-04-12 2670 int ret;
3a4bfa091c46e9 Rahul Kumar Singh 2021-07-26 2671
7935785240508c John Harrison 2021-07-26 2672 /* NB: For both of these, zero means disabled. */
568944af44e753 John Harrison 2022-10-06 2673 GEM_BUG_ON(overflows_type(engine->props.timeslice_duration_ms * 1000,
568944af44e753 John Harrison 2022-10-06 2674 execution_quantum));
568944af44e753 John Harrison 2022-10-06 2675 GEM_BUG_ON(overflows_type(engine->props.preempt_timeout_ms * 1000,
568944af44e753 John Harrison 2022-10-06 2676 preemption_timeout));
2584b3549f4c40 John Harrison 2022-04-12 2677 execution_quantum = engine->props.timeslice_duration_ms * 1000;
2584b3549f4c40 John Harrison 2022-04-12 2678 preemption_timeout = engine->props.preempt_timeout_ms * 1000;
2584b3549f4c40 John Harrison 2022-04-12 2679
cec82816d0d018 Vinay Belgaumkar 2024-03-05 @2680 if (ce && (ce->flags & BIT(CONTEXT_LOW_LATENCY)))
^^
NULL check is too late.
cec82816d0d018 Vinay Belgaumkar 2024-03-05 2681 slpc_ctx_freq_req |= SLPC_CTX_FREQ_REQ_IS_COMPUTE;
cec82816d0d018 Vinay Belgaumkar 2024-03-05 2682
2584b3549f4c40 John Harrison 2022-04-12 2683 __guc_context_policy_start_klv(&policy, ce->guc_id.id);
2584b3549f4c40 John Harrison 2022-04-12 2684
2584b3549f4c40 John Harrison 2022-04-12 2685 __guc_context_policy_add_priority(&policy, ce->guc_state.prio);
2584b3549f4c40 John Harrison 2022-04-12 2686 __guc_context_policy_add_execution_quantum(&policy, execution_quantum);
2584b3549f4c40 John Harrison 2022-04-12 2687 __guc_context_policy_add_preemption_timeout(&policy, preemption_timeout);
cec82816d0d018 Vinay Belgaumkar 2024-03-05 2688 __guc_context_policy_add_slpc_ctx_freq_req(&policy, slpc_ctx_freq_req);
2584b3549f4c40 John Harrison 2022-04-12 2689
2584b3549f4c40 John Harrison 2022-04-12 2690 if (engine->flags & I915_ENGINE_WANT_FORCED_PREEMPTION)
2584b3549f4c40 John Harrison 2022-04-12 2691 __guc_context_policy_add_preempt_to_idle(&policy, 1);
2584b3549f4c40 John Harrison 2022-04-12 2692
2584b3549f4c40 John Harrison 2022-04-12 2693 ret = __guc_context_set_context_policies(guc, &policy, loop);
2584b3549f4c40 John Harrison 2022-04-12 2694
2584b3549f4c40 John Harrison 2022-04-12 2695 spin_lock_irqsave(&ce->guc_state.lock, flags);
6c82c75230b87d Daniele Ceraolo Spurio 2022-07-27 2696 if (ret != 0)
2584b3549f4c40 John Harrison 2022-04-12 2697 set_context_policy_required(ce);
2584b3549f4c40 John Harrison 2022-04-12 2698 else
2584b3549f4c40 John Harrison 2022-04-12 2699 clr_context_policy_required(ce);
2584b3549f4c40 John Harrison 2022-04-12 2700 spin_unlock_irqrestore(&ce->guc_state.lock, flags);
2584b3549f4c40 John Harrison 2022-04-12 2701
2584b3549f4c40 John Harrison 2022-04-12 2702 return ret;
3a4cdf1982f05d Matthew Brost 2021-07-21 2703 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
More information about the Intel-gfx
mailing list