Return-Path: Received: from mail-bl2nam02on0122.outbound.protection.outlook.com ([104.47.38.122]:14153 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932942AbeCCW3R (ORCPT ); Sat, 3 Mar 2018 17:29:17 -0500 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Monk Liu , Alex Deucher , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 51/84] drm/amdgpu:fix virtual dce bug Date: Sat, 3 Mar 2018 22:26:29 +0000 Message-ID: <20180303222518.26271-51-alexander.levin@microsoft.com> References: <20180303222518.26271-1-alexander.levin@microsoft.com> In-Reply-To: <20180303222518.26271-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Monk Liu [ Upstream commit 129d65c18ecfb249aceb540c31fdaf79bd5a11ff ] this fix the issue that access memory after freed after driver unloaded. Signed-off-by: Monk Liu Acked-by: Alex Deucher Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/dce_virtual.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c b/drivers/gpu/drm/amd= /amdgpu/dce_virtual.c index b9ee9073cb0d..f3f93b6b51ef 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_virtual.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_virtual.c @@ -437,6 +437,8 @@ static int dce_virtual_sw_fini(void *handle) drm_kms_helper_poll_fini(adev->ddev); =20 drm_mode_config_cleanup(adev->ddev); + /* clear crtcs pointer to avoid dce irq finish routine access freed data = */ + memset(adev->mode_info.crtcs, 0, sizeof(adev->mode_info.crtcs[0]) * AMDGP= U_MAX_CRTCS); adev->mode_info.mode_config_initialized =3D false; return 0; } @@ -723,7 +725,7 @@ static void dce_virtual_set_crtc_vblank_interrupt_state= (struct amdgpu_device *ad int crtc, enum amdgpu_interrupt_state state) { - if (crtc >=3D adev->mode_info.num_crtc) { + if (crtc >=3D adev->mode_info.num_crtc || !adev->mode_info.crtcs[crtc]) { DRM_DEBUG("invalid crtc %d\n", crtc); return; } --=20 2.14.1