@@ -88,6 +88,9 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, struct pci_dev *pdev)
return NULL;
kfd = kzalloc(sizeof(*kfd), GFP_KERNEL);
+ if (!kfd)
+ return NULL;
+
kfd->kgd = kgd;
kfd->device_info = device_info;
kfd->pdev = pdev;
@@ -317,7 +317,7 @@ static struct mqd_manager *get_mqd_manager_nocpsch(struct device_queue_manager *
{
struct mqd_manager *mqd;
- BUG_ON(!dqm || type > KFD_MQD_TYPE_MAX);
+ BUG_ON(!dqm || type >= KFD_MQD_TYPE_MAX);
pr_debug("kfd: In func %s mqd type %d\n", __func__, type);
@@ -437,6 +437,7 @@ struct mqd_manager *mqd_manager_init(enum KFD_MQD_TYPE type, struct kfd_dev *dev
mqd->uninitialize = uninitialize;
break;
default:
+ kfree(mqd);
return NULL;
break;
}
@@ -85,9 +85,10 @@ static int pm_allocate_runlist_ib(struct packet_manager *pm, unsigned int **rl_b
BUG_ON(!pm);
BUG_ON(pm->allocated == true);
+ BUG_ON(is_over_subscription == NULL);
pm_calc_rlib_size(pm, rl_buffer_size, is_over_subscription);
- if (is_over_subscription &&
+ if (*is_over_subscription &&
sched_policy == KFD_SCHED_POLICY_HWS_NO_OVERSUBSCRIPTION)
return -EFAULT;
@@ -146,15 +146,15 @@ static struct kfd_process *create_process(const struct task_struct *thread)
process = kzalloc(sizeof(*process), GFP_KERNEL);
if (!process)
- goto err_alloc;
+ goto err_alloc_process;
process->queues = kmalloc_array(INITIAL_QUEUE_ARRAY_SIZE, sizeof(process->queues[0]), GFP_KERNEL);
if (!process->queues)
- goto err_alloc;
+ goto err_alloc_queues;
process->pasid = radeon_kfd_pasid_alloc();
if (process->pasid == 0)
- goto err_alloc;
+ goto err_alloc_pasid;
mutex_init(&process->mutex);
@@ -178,9 +178,11 @@ err_process_pqm_init:
radeon_kfd_pasid_free(process->pasid);
list_del(&process->processes_list);
thread->mm->kfd_process = NULL;
-err_alloc:
+err_alloc_pasid:
kfree(process->queues);
+err_alloc_queues:
kfree(process);
+err_alloc_process:
return ERR_PTR(err);
}
Signed-off-by: Oded Gabbay <oded.gabbay@amd.com> --- drivers/gpu/hsa/radeon/kfd_device.c | 3 +++ drivers/gpu/hsa/radeon/kfd_device_queue_manager.c | 2 +- drivers/gpu/hsa/radeon/kfd_mqd_manager.c | 1 + drivers/gpu/hsa/radeon/kfd_packet_manager.c | 3 ++- drivers/gpu/hsa/radeon/kfd_process.c | 10 ++++++---- 5 files changed, 13 insertions(+), 6 deletions(-)