[radeon-alex:amd-staging-drm-next 1/4] drivers/gpu/drm/scheduler/gpu_scheduler.c:195 drm_sched_entity_init() error: potential null dereference 'entity->rq_list'. (kcalloc returns null)

kbuild test robot lkp at intel.com
Mon Aug 13 10:21:24 UTC 2018


tree:   git://people.freedesktop.org/~agd5f/linux.git amd-staging-drm-next
head:   53d5f1e4a6d91457678a24b03d0a66edafb800ea
commit: 711c989d235ffd044fb04b971049e204b33fde3f [1/4] drm/scheduler: add a list of run queues to the entity

New smatch warnings:
drivers/gpu/drm/scheduler/gpu_scheduler.c:195 drm_sched_entity_init() error: potential null dereference 'entity->rq_list'.  (kcalloc returns null)

Old smatch warnings:
include/asm-generic/atomic-instrumented.h:365 cmpxchg_size() error: uninitialized symbol '__ret'.

vim +195 drivers/gpu/drm/scheduler/gpu_scheduler.c

   160	
   161	/**
   162	 * drm_sched_entity_init - Init a context entity used by scheduler when
   163	 * submit to HW ring.
   164	 *
   165	 * @entity: scheduler entity to init
   166	 * @rq_list: the list of run queue on which jobs from this
   167	 *           entity can be submitted
   168	 * @num_rq_list: number of run queue in rq_list
   169	 * @guilty: atomic_t set to 1 when a job on this queue
   170	 *          is found to be guilty causing a timeout
   171	 *
   172	 * Note: the rq_list should have atleast one element to schedule
   173	 *       the entity
   174	 *
   175	 * Returns 0 on success or a negative error code on failure.
   176	*/
   177	int drm_sched_entity_init(struct drm_sched_entity *entity,
   178				  struct drm_sched_rq **rq_list,
   179				  unsigned int num_rq_list,
   180				  atomic_t *guilty)
   181	{
   182		int i;
   183	
   184		if (!(entity && rq_list && num_rq_list > 0 && rq_list[0]))
   185			return -EINVAL;
   186	
   187		memset(entity, 0, sizeof(struct drm_sched_entity));
   188		INIT_LIST_HEAD(&entity->list);
   189		entity->rq = rq_list[0];
   190		entity->guilty = guilty;
   191		entity->num_rq_list = num_rq_list;
   192		entity->rq_list = kcalloc(num_rq_list, sizeof(struct drm_sched_rq *),
   193					GFP_KERNEL);
   194		for (i = 0; i < num_rq_list; ++i)
 > 195			entity->rq_list[i] = rq_list[i];
   196		entity->last_scheduled = NULL;
   197	
   198		spin_lock_init(&entity->rq_lock);
   199		spsc_queue_init(&entity->job_queue);
   200	
   201		atomic_set(&entity->fence_seq, 0);
   202		entity->fence_context = dma_fence_context_alloc(2);
   203	
   204		return 0;
   205	}
   206	EXPORT_SYMBOL(drm_sched_entity_init);
   207	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation


More information about the dri-devel mailing list