Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] drm/amdkfd: pdd memory leak on kfd_init_apertures() error path
--

commit d555bec2fa5191157e4dad2138f047c49150f26e
Author: Henry Martin <[email protected]>

    drm/amdkfd: fix doorbell allocation race creating duplicate allocations

This patch introduces a per-process-device mutex to serialize process doorbell
allocation. It adds mutex initialization and destruction to the kfd process
lifecycle.

> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c 
> b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> index 226f52626e849..51b0df4984945 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c

[ ... ]

> @@ -1802,6 +1803,7 @@ struct kfd_process_device 
> *kfd_create_process_device_data(struct kfd_node *dev,
>       pdd->dev = dev;
>       INIT_LIST_HEAD(&pdd->qpd.queues_list);
>       INIT_LIST_HEAD(&pdd->qpd.priv_queue_list);
> +     mutex_init(&pdd->doorbell_mutex);
>       pdd->qpd.dqm = dev->dqm;
>       pdd->qpd.pqm = &p->pqm;
>       pdd->qpd.evicted = 0;

[Severity: Medium]
Will this mutex and the pdd struct be leaked if kfd_init_apertures() fails?

Looking at create_process(), if kfd_init_apertures() successfully allocates
one or more pdd structs but then encounters an error and fails, the error
handling path jumps to err_init_apertures:

create_process() {
    ...
    err = kfd_init_apertures(process);
    if (err != 0)
        goto err_init_apertures;
    ...
err_init_svm_range_list:
    kfd_process_free_outstanding_kfd_bos(process);
    kfd_process_destroy_pdds(process);
err_init_apertures:
    pqm_uninit(&process->pqm);
    ...
}

Because err_init_apertures bypasses the call to kfd_process_destroy_pdds(),
does this mean the newly initialized doorbell_mutex and the allocated pdd
structs are leaked?

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to