<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#008000;margin:15pt;" align="Left">
[Public]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Reviewed-by: Alex Deucher <alexander.deucher@amd.com><br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Flora Cui <flora.cui@amd.com><br>
<b>Sent:</b> Monday, December 6, 2021 1:34 AM<br>
<b>To:</b> =guchun.chen@amd.com <=guchun.chen@amd.com>; Yuan, Perry <Perry.Yuan@amd.com>; Shi, Leslie <Yuliang.Shi@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Shi, Leslie <Yuliang.Shi@amd.com>; Cui, Flora <Flora.Cui@amd.com><br>
<b>Subject:</b> [PATCH 2/2] drm/amdgpu: free vkms_output after use</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Signed-off-by: Flora Cui <flora.cui@amd.com><br>
Reviewed-by: Leslie Shi <Yuliang.Shi@amd.com><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c | 16 +++++++++-------<br>
 1 file changed, 9 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c<br>
index acc2d31ea93f..af3a2f8c12b4 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vkms.c<br>
@@ -480,6 +480,11 @@ static int amdgpu_vkms_sw_init(void *handle)<br>
         int r, i;<br>
         struct amdgpu_device *adev = (struct amdgpu_device *)handle;<br>
 <br>
+       adev->amdgpu_vkms_output = kcalloc(adev->mode_info.num_crtc,<br>
+               sizeof(struct amdgpu_vkms_output), GFP_KERNEL);<br>
+       if (!adev->amdgpu_vkms_output)<br>
+               return -ENOMEM;<br>
+<br>
         adev_to_drm(adev)->max_vblank_count = 0;<br>
 <br>
         adev_to_drm(adev)->mode_config.funcs = &amdgpu_vkms_mode_funcs;<br>
@@ -496,10 +501,6 @@ static int amdgpu_vkms_sw_init(void *handle)<br>
         if (r)<br>
                 return r;<br>
 <br>
-       adev->amdgpu_vkms_output = kcalloc(adev->mode_info.num_crtc, sizeof(struct amdgpu_vkms_output), GFP_KERNEL);<br>
-       if (!adev->amdgpu_vkms_output)<br>
-               return -ENOMEM;<br>
-<br>
         /* allocate crtcs, encoders, connectors */<br>
         for (i = 0; i < adev->mode_info.num_crtc; i++) {<br>
                 r = amdgpu_vkms_output_init(adev_to_drm(adev), &adev->amdgpu_vkms_output[i], i);<br>
@@ -522,12 +523,13 @@ static int amdgpu_vkms_sw_fini(void *handle)<br>
                 if (adev->mode_info.crtcs[i])<br>
                         hrtimer_cancel(&adev->mode_info.crtcs[i]->vblank_timer);<br>
 <br>
-       kfree(adev->mode_info.bios_hardcoded_edid);<br>
-       kfree(adev->amdgpu_vkms_output);<br>
-<br>
         drm_kms_helper_poll_fini(adev_to_drm(adev));<br>
+       drm_mode_config_cleanup(adev_to_drm(adev));<br>
 <br>
         adev->mode_info.mode_config_initialized = false;<br>
+<br>
+       kfree(adev->mode_info.bios_hardcoded_edid);<br>
+       kfree(adev->amdgpu_vkms_output);<br>
         return 0;<br>
 }<br>
 <br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>