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

drm/amdgpu: fix ref count leak in amdgpu_display_crtc_set_config

in amdgpu_display_crtc_set_config, the call to pm_runtime_get_sync
increments the counter even in case of failure, leading to incorrect
ref count. In case of failure, decrement the ref count before returning.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Navid Emamdoost and committed by
Alex Deucher
e008fa6f 5509ac65

+3 -2
+3 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
··· 282 282 283 283 ret = pm_runtime_get_sync(dev->dev); 284 284 if (ret < 0) 285 - return ret; 285 + goto out; 286 286 287 287 ret = drm_crtc_helper_set_config(set, ctx); 288 288 ··· 297 297 take the current one */ 298 298 if (active && !adev->have_disp_power_ref) { 299 299 adev->have_disp_power_ref = true; 300 - return ret; 300 + goto out; 301 301 } 302 302 /* if we have no active crtcs, then drop the power ref 303 303 we got before */ ··· 306 306 adev->have_disp_power_ref = false; 307 307 } 308 308 309 + out: 309 310 /* drop the power reference we got coming in here */ 310 311 pm_runtime_put_autosuspend(dev->dev); 311 312 return ret;