mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wentao Liang <vulab@iscas.ac.cn>
To: Hans de Goede <hansg@kernel.org>
Cc: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
	"Maximilian Luz" <luzmaximilian@gmail.com>,
	platform-driver-x86@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH v2 1/2] platform/surface: aggregator: Fix wrong completion list for pending packets
Date: Sat, 07 Nov 2026 08:07:30 +0000	[thread overview]
Message-ID: <20261107080730.1-vulab@iscas.ac.cn> (raw)
In-Reply-To: <20261107080730.0-vulab@iscas.ac.cn>

ssh_ptl_shutdown() takes the packets it has to cancel out of the queue
and out of the pending set and collects them in two local lists, which
are drained once both locks have been dropped. Packets from the pending
set are moved to complete_p through pending_node, as their queue_node
may still be in use by the queue when a pending packet is re-queued for
retransmission. The move itself, however, targets complete_q.

An entry added that way is linked into complete_q via pending_node,
while the loop that drains complete_q looks the entry up with
queue_node. The two nodes are at different offsets in struct
ssh_packet, so list_for_each_entry() derives a packet pointer that is
shifted by that difference: the state bit is updated at the wrong
offset and the completion and reference-drop run on an object that is
not the packet the list entry belongs to. At the same time complete_p
stays empty and its drain loop never runs.

Move the pending packets to complete_p as intended.

Fixes: c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")
Cc: stable@vger.kernel.org
Acked-by: Maximilian Luz <luzmaximilian@gmail.com>
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/platform/surface/aggregator/ssh_packet_layer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/surface/aggregator/ssh_packet_layer.c b/drivers/platform/surface/aggregator/ssh_packet_layer.c
index 3dd22856570f..a51395942747 100644
--- a/drivers/platform/surface/aggregator/ssh_packet_layer.c
+++ b/drivers/platform/surface/aggregator/ssh_packet_layer.c
@@ -1983,7 +1983,7 @@ void ssh_ptl_shutdown(struct ssh_ptl *ptl)
 		smp_mb__before_atomic();
 		clear_bit(SSH_PACKET_SF_PENDING_BIT, &p->state);
 
-		list_move_tail(&p->pending_node, &complete_q);
+		list_move_tail(&p->pending_node, &complete_p);
 	}
 	atomic_set(&ptl->pending.count, 0);
 	spin_unlock(&ptl->pending.lock);

-- 
2.34.1


      parent reply	other threads:[~2026-11-07  8:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07  8:07 [PATCH v2 0/2] platform/surface: aggregator: Fix packet list handling in ssh_ptl_shutdown() Wentao Liang
2026-11-07  8:07 ` [PATCH v2 2/2] platform/surface: aggregator: Fix use-after-free " Wentao Liang
2026-11-07  8:07 ` Wentao Liang [this message]

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=20261107080730.1-vulab@iscas.ac.cn \
    --to=vulab@iscas.ac.cn \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luzmaximilian@gmail.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®