The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH v3 26/44] media: cec: Serialize exclusive follower delivery
@ 2026-07-07 15:06 Ruoyu Wang
  2026-07-07 15:12 ` Ruoyu Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Ruoyu Wang @ 2026-07-07 15:06 UTC (permalink / raw)
  To: hverkuil, mchehab; +Cc: linux-media, linux-kernel, Ruoyu Wang

cec_receive_notify() read the exclusive follower pointer without the adapter lock. Serialize the no-follower check and message delivery against mode changes and release.
Signed-off-by: Ruoyu Wang <ruoyuw560@gmail.com>
---
 drivers/media/cec/core/cec-adap.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/media/cec/core/cec-adap.c b/drivers/media/cec/core/cec-adap.c
index a90cb84a4b4d0..b616ed382c0e7 100644
--- a/drivers/media/cec/core/cec-adap.c
+++ b/drivers/media/cec/core/cec-adap.c
@@ -2219,9 +2219,13 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
 		 * Unprocessed messages are aborted if userspace isn't doing
 		 * any processing either.
 		 */
+		mutex_lock(&adap->lock);
 		if (!is_broadcast && !is_reply && !adap->follower_cnt &&
-		    !adap->cec_follower && msg->msg[1] != CEC_MSG_FEATURE_ABORT)
+		    !adap->cec_follower && msg->msg[1] != CEC_MSG_FEATURE_ABORT) {
+			mutex_unlock(&adap->lock);
 			return cec_feature_abort(adap, msg);
+		}
+		mutex_unlock(&adap->lock);
 		break;
 	}
 
@@ -2234,10 +2238,12 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
 	 * Send to the exclusive follower if there is one, otherwise send
 	 * to all followers.
 	 */
+	mutex_lock(&adap->lock);
 	if (adap->cec_follower)
 		cec_queue_msg_fh(adap->cec_follower, msg);
 	else
 		cec_queue_msg_followers(adap, msg);
+	mutex_unlock(&adap->lock);
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3 26/44] media: cec: Serialize exclusive follower delivery
  2026-07-07 15:06 [PATCH v3 26/44] media: cec: Serialize exclusive follower delivery Ruoyu Wang
@ 2026-07-07 15:12 ` Ruoyu Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Ruoyu Wang @ 2026-07-07 15:12 UTC (permalink / raw)
  To: hverkuil; +Cc: mchehab, linux-media, linux-kernel

The "v3 26/44" in the subject is a numbering artifact from batch
generation. This patch was intended as a standalone fix, not part
of a larger series. Please treat it as [PATCH] only. Apologies for
the confusion.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-07 15:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 15:06 [PATCH v3 26/44] media: cec: Serialize exclusive follower delivery Ruoyu Wang
2026-07-07 15:12 ` Ruoyu Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox