[v3 4/6] drm/amdgpu: enhance error handling in function amdgpu_pci_probe()
Gerry Liu
gerry at linux.alibaba.com
Thu Jan 9 03:34:37 UTC 2025
> 2025年1月9日 00:08,Mario Limonciello <mario.limonciello at amd.com> 写道:
>
> On 1/8/2025 02:56, Jiang Liu wrote:
>> Enhance error handling in function amdgpu_pci_probe() to avoid
>> possible resource leakage.
>> Signed-off-by: Jiang Liu <gerry at linux.alibaba.com>
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 12 +++++++++---
>> 1 file changed, 9 insertions(+), 3 deletions(-)
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
>> index 41d1b06be600..f8deca2f2696 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
>> @@ -2346,16 +2346,16 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
>> msleep(5000);
>> goto retry_init;
>> } else if (ret) {
>> - goto err_pci;
>> + goto unload_kms;
>
> This label change looks wrong to me. If you fail to amdgpu_driver_load_kms(), why would you amdgpu_driver_unload_kms()?
>
> amdgpu_driver_load_kms() has cleanup handling already to call amdgpu_driver_unload_kms()
This goto is to handle failure of drm_dev_register() instead of failure of amdgpu_driver_load_kms().
Thanks,
Gerry
>
>> }
>> ret = amdgpu_xcp_dev_register(adev, ent);
>> if (ret)
>> - goto err_pci;
>> + goto unplug_drm;
>> ret = amdgpu_amdkfd_drm_client_create(adev);
>> if (ret)
>> - goto err_pci;
>> + goto deregister_xcp;
>> /*
>> * 1. don't init fbdev on hw without DCE
>> @@ -2424,6 +2424,12 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
>> return 0;
>> +deregister_xcp:
>> + amdgpu_xcp_dev_deregister(adev);
>> +unplug_drm:
>> + drm_dev_unplug(ddev);
>> +unload_kms:
>> + amdgpu_driver_unload_kms(ddev);
>> err_pci:
>> pci_disable_device(pdev);
>> return ret;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20250109/4d70b5c0/attachment.htm>
More information about the amd-gfx
mailing list