From: sashiko-bot@kernel.org
To: "Bart Verwilst" <bart@verwilst.be>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v2 1/2] drm/amd/display: don't release an MST payload that holds no time slots
Date: Thu, 26 Nov 2026 14:17:19 +0000 [thread overview]
Message-ID: <sashiko-outbox-235685@kernel.org> (raw)
In-Reply-To: <20261126110042.14612-2-bart@verwilst.be>
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 <bart@verwilst.be>
> 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 <bart@verwilst.be>
[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/20261126110042.14612-1-bart@verwilst.be?part=1
next prev parent reply other threads:[~2026-11-26 14:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 11:00 [PATCH v2 0/2] drm/amd/display: fix GPU hang on SST<->MST switch of the same sink Bart Verwilst
2026-11-26 11:00 ` [PATCH v2 1/2] drm/amd/display: don't release an MST payload that holds no time slots Bart Verwilst
2026-11-26 14:17 ` sashiko-bot [this message]
2026-11-26 11:00 ` [PATCH v2 2/2] drm/amd/display: don't tear down a shared link for a stale SST/MST stream Bart Verwilst
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-235685@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=amd-gfx@lists.freedesktop.org \
--cc=bart@verwilst.be \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox