Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] drm/amd/display: port malloc ref leak on early return when vc_start_slot < 0 - [Low] drm/amd/display: missing Fixes trailer on MST payload deallocation fix --
commit 7f970cf45d3ae6670fde9a6c3493d4e1852b6853 Author: Bart Verwilst <[email protected]> > drm/amd/display: don't release an MST payload that holds no time slots > > dm_helpers_dp_mst_update_mst_mgr_for_deallocation() calls > drm_dp_remove_payload_part2() unconditionally. That function decrements > payload_count and moves next_start_slot back by the payload's time > slots. If the payload was never added with drm_dp_add_payload_part1(), > or was already released, both counters underflow. Every payload > allocated afterwards then starts at a bogus slot and ACT never > completes. > > This can happen when the same stream is disabled twice, e.g. first by > link_set_all_streams_dpms_off_for_link() during a destructive link > verification and then again when userspace disables its CRTC, or when > the stream enable was aborted before its payload was allocated. > > drm_dp_add_payload_part1() sets vc_start_slot and > drm_dp_remove_payload_part2() resets it to -1, so a negative > vc_start_slot means there is nothing to release. Return early in that > case. > > Signed-off-by: Bart Verwilst <[email protected]> [Severity: Low] Should this bug fix include a Fixes: tag for commit 83a79dd6f4fb ("drm/amd/display: adjust flow for deallocation mst payload")? > diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c > b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c > index 6192c0f6086db..bc26f65d51ffe 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c > @@ -524,6 +524,22 @@ void dm_helpers_dp_mst_update_mst_mgr_for_deallocation( > mst_mgr = &aconnector->mst_root->mst_mgr; > mst_state = to_drm_dp_mst_topology_state(mst_mgr->base.state); > new_payload = drm_atomic_get_mst_payload_state(mst_state, > aconnector->mst_output_port); > + if (!new_payload) > + return; > + > + /* > + * Only a payload that went through drm_dp_add_payload_part1() holds > + * time slots in the manager (vc_start_slot >= 0). Releasing a payload > + * that was never added, or releasing one twice, would underflow > + * payload_count and next_start_slot. > + */ > + if (new_payload->vc_start_slot < 0) { > + drm_dbg_kms(mst_mgr->dev, > + "MST payload for VCPI %d holds no time slots, > nothing to release\n", > + new_payload->vcpi); > + return; > + } [Severity: Medium] Does returning early here leak a malloc reference on new_payload->port when new_payload->delete is set? When userspace disables the CRTC after link_set_all_streams_dpms_off_for_link() has already reset vc_start_slot to -1, drm_dp_mst_duplicate_state() takes a new port malloc reference and drm_dp_atomic_release_time_slots() sets new_payload->delete = true. Because drm_dp_mst_destroy_state() skips payloads with delete set: drivers/gpu/drm/display/drm_dp_mst_topology.c:drm_dp_mst_destroy_state() { list_for_each_entry_safe(pos, tmp, &mst_state->payloads, next) { /* We only keep references to ports with active payloads */ if (!pos->delete) drm_dp_mst_put_port_malloc(pos->port); kfree(pos); } } that reference is normally dropped by drm_dp_remove_payload_part2(), which also resets new_payload->payload_allocation_status to DRM_DP_MST_PAYLOAD_ALLOCATION_NONE after drm_dp_remove_payload_part1() set it to DRM_DP_MST_PAYLOAD_ALLOCATION_LOCAL. Skipping drm_dp_remove_payload_part2() without doing both permanently leaks new_payload->port and leaves payload_allocation_status at DRM_DP_MST_PAYLOAD_ALLOCATION_LOCAL. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
