Re:Re: [PATCH] amdgpu: fixes memleak issue when init failed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Christian König" <christian.koenig@xxxxxxx>
Date: 2020-04-21 19:22:49
To:  Bernard Zhao <bernard@xxxxxxxx>,Alex Deucher <alexander.deucher@xxxxxxx>,"David (ChunMing) Zhou" <David1.Zhou@xxxxxxx>,David Airlie <airlied@xxxxxxxx>,Daniel Vetter <daniel@xxxxxxxx>,Tom St Denis <tom.stdenis@xxxxxxx>,Ori Messinger <Ori.Messinger@xxxxxxx>,Sam Ravnborg <sam@xxxxxxxxxxxx>,amd-gfx@xxxxxxxxxxxxxxxxxxxxx,dri-devel@xxxxxxxxxxxxxxxxxxxxx,linux-kernel@xxxxxxxxxxxxxxx
Cc:  opensource.kernel@xxxxxxxx
Subject: Re: [PATCH] amdgpu: fixes memleak issue when init failed>Am 21.04.20 um 13:17 schrieb Bernard Zhao:
>> VRAM manager and DRM MM when init failed, there is no operaction
>> to free kzalloc memory & remove device file.
>> This will lead to memleak & cause stability issue.
>
>NAK, failure to create sysfs nodes are not critical.
>
>Christian.
>

OK, get it.
By the way, should i modify this patch to just handle <kfree(mgr)> in error branch, or that it is also unnecessary?

Regards,
Bernard

>>
>> Signed-off-by: Bernard Zhao <bernard@xxxxxxxx>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 24 ++++++++++++++++----
>>   1 file changed, 19 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> index 82a3299e53c0..4c5fb153e6b4 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c
>> @@ -175,30 +175,44 @@ static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man,
>>   	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_total);
>>   	if (ret) {
>>   		DRM_ERROR("Failed to create device file mem_info_vram_total\n");
>> -		return ret;
>> +		goto VRAM_TOTAL_FAIL;
>>   	}
>>   	ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
>>   	if (ret) {
>>   		DRM_ERROR("Failed to create device file mem_info_vis_vram_total\n");
>> -		return ret;
>> +		goto VIS_VRAM_TOTA_FAIL;
>>   	}
>>   	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_used);
>>   	if (ret) {
>>   		DRM_ERROR("Failed to create device file mem_info_vram_used\n");
>> -		return ret;
>> +		goto VRAM_USED_FAIL;
>>   	}
>>   	ret = device_create_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
>>   	if (ret) {
>>   		DRM_ERROR("Failed to create device file mem_info_vis_vram_used\n");
>> -		return ret;
>> +		goto VIS_VRAM_USED_FAIL;
>>   	}
>>   	ret = device_create_file(adev->dev, &dev_attr_mem_info_vram_vendor);
>>   	if (ret) {
>>   		DRM_ERROR("Failed to create device file mem_info_vram_vendor\n");
>> -		return ret;
>> +		goto VRAM_VERDOR_FAIL;
>>   	}
>>   
>>   	return 0;
>> +
>> +VRAM_VERDOR_FAIL:
>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_used);
>> +VIS_VRAM_USED_FAIL:
>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vram_used);
>> +RVAM_USED_FAIL:
>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vis_vram_total);
>> +VIS_VRAM_TOTA_FAIL:
>> +	device_remove_file(adev->dev, &dev_attr_mem_info_vram_total);
>> +VRAM_TOTAL_FAIL:
>> +	kfree(mgr);
>> +	man->priv = NULL;
>> +
>> +	return ret;
>>   }
>>   
>>   /**
>


_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux