Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: Release hive reference properly

xgmi hive reference is taken on function entry, but not released
correctly for all paths. Use __free() to release reference properly.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Ce Sun <cesun102@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Lijo Lazar and committed by
Alex Deucher
c1456fad 2a7a794e

+7 -4
+3 -4
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 6937 6937 { 6938 6938 struct drm_device *dev = pci_get_drvdata(pdev); 6939 6939 struct amdgpu_device *adev = drm_to_adev(dev); 6940 - struct amdgpu_hive_info *hive = amdgpu_get_xgmi_hive(adev); 6940 + struct amdgpu_hive_info *hive __free(xgmi_put_hive) = 6941 + amdgpu_get_xgmi_hive(adev); 6941 6942 struct amdgpu_reset_context reset_context; 6942 6943 struct list_head device_list; 6943 6944 ··· 6977 6976 amdgpu_device_recovery_get_reset_lock(adev, &device_list); 6978 6977 amdgpu_device_halt_activities(adev, NULL, &reset_context, &device_list, 6979 6978 hive, false); 6980 - if (hive) { 6979 + if (hive) 6981 6980 mutex_unlock(&hive->hive_lock); 6982 - amdgpu_put_xgmi_hive(hive); 6983 - } 6984 6981 return PCI_ERS_RESULT_NEED_RESET; 6985 6982 case pci_channel_io_perm_failure: 6986 6983 /* Permanent error, prepare for device removal */
+4
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h
··· 126 126 127 127 void amgpu_xgmi_set_max_speed_width(struct amdgpu_device *adev, 128 128 uint16_t max_speed, uint8_t max_width); 129 + 130 + /* Cleanup macro for use with __free(xgmi_put_hive) */ 131 + DEFINE_FREE(xgmi_put_hive, struct amdgpu_hive_info *, if (_T) amdgpu_put_xgmi_hive(_T)) 132 + 129 133 #endif