mirror of https://gitee.com/openkylin/linux.git
drm/amd/display: Fix memleaks when atomic check fails.
While checking plane states for updates during atomic check, we create dc_plane_states in preparation. These dc states should be freed if something errors. Although the input transfer function is also freed by dc_plane_state_release(), we should free it (on error) under the same scope as where it is created. Signed-off-by: Leo (Sunpeng) Li <sunpeng.li@amd.com> Reviewed-by: Harry Wentland <Harry.Wentland@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
d179664a2a
commit
8c45c5db84
|
@ -1982,6 +1982,10 @@ static int fill_plane_attributes(struct amdgpu_device *adev,
|
||||||
* every time.
|
* every time.
|
||||||
*/
|
*/
|
||||||
ret = amdgpu_dm_set_degamma_lut(crtc_state, dc_plane_state);
|
ret = amdgpu_dm_set_degamma_lut(crtc_state, dc_plane_state);
|
||||||
|
if (ret) {
|
||||||
|
dc_transfer_func_release(dc_plane_state->in_transfer_func);
|
||||||
|
dc_plane_state->in_transfer_func = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -4737,6 +4741,7 @@ static int dm_update_planes_state(struct dc *dc,
|
||||||
*lock_and_validation_needed = true;
|
*lock_and_validation_needed = true;
|
||||||
|
|
||||||
} else { /* Add new planes */
|
} else { /* Add new planes */
|
||||||
|
struct dc_plane_state *dc_new_plane_state;
|
||||||
|
|
||||||
if (drm_atomic_plane_disabling(plane->state, new_plane_state))
|
if (drm_atomic_plane_disabling(plane->state, new_plane_state))
|
||||||
continue;
|
continue;
|
||||||
|
@ -4755,34 +4760,45 @@ static int dm_update_planes_state(struct dc *dc,
|
||||||
|
|
||||||
WARN_ON(dm_new_plane_state->dc_state);
|
WARN_ON(dm_new_plane_state->dc_state);
|
||||||
|
|
||||||
dm_new_plane_state->dc_state = dc_create_plane_state(dc);
|
dc_new_plane_state = dc_create_plane_state(dc);
|
||||||
|
if (!dc_new_plane_state) {
|
||||||
|
ret = -EINVAL;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
DRM_DEBUG_DRIVER("Enabling DRM plane: %d on DRM crtc %d\n",
|
DRM_DEBUG_DRIVER("Enabling DRM plane: %d on DRM crtc %d\n",
|
||||||
plane->base.id, new_plane_crtc->base.id);
|
plane->base.id, new_plane_crtc->base.id);
|
||||||
|
|
||||||
if (!dm_new_plane_state->dc_state) {
|
ret = fill_plane_attributes(
|
||||||
ret = -EINVAL;
|
new_plane_crtc->dev->dev_private,
|
||||||
|
dc_new_plane_state,
|
||||||
|
new_plane_state,
|
||||||
|
new_crtc_state);
|
||||||
|
if (ret) {
|
||||||
|
dc_plane_state_release(dc_new_plane_state);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = fill_plane_attributes(
|
/*
|
||||||
new_plane_crtc->dev->dev_private,
|
* Any atomic check errors that occur after this will
|
||||||
dm_new_plane_state->dc_state,
|
* not need a release. The plane state will be attached
|
||||||
new_plane_state,
|
* to the stream, and therefore part of the atomic
|
||||||
new_crtc_state);
|
* state. It'll be released when the atomic state is
|
||||||
if (ret)
|
* cleaned.
|
||||||
return ret;
|
*/
|
||||||
|
|
||||||
if (!dc_add_plane_to_context(
|
if (!dc_add_plane_to_context(
|
||||||
dc,
|
dc,
|
||||||
dm_new_crtc_state->stream,
|
dm_new_crtc_state->stream,
|
||||||
dm_new_plane_state->dc_state,
|
dc_new_plane_state,
|
||||||
dm_state->context)) {
|
dm_state->context)) {
|
||||||
|
|
||||||
|
dc_plane_state_release(dc_new_plane_state);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dm_new_plane_state->dc_state = dc_new_plane_state;
|
||||||
|
|
||||||
/* Tell DC to do a full surface update every time there
|
/* Tell DC to do a full surface update every time there
|
||||||
* is a plane change. Inefficient, but works for now.
|
* is a plane change. Inefficient, but works for now.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue