* FAILED: patch "[PATCH] media: cec: disable delayed work before freeing an" failed to apply to 6.6-stable tree
@ 2026-09-09 10:58 gregkh
2026-11-29 15:27 ` Dickson Wu via B4 Relay
0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2026-09-09 10:58 UTC (permalink / raw)
To: birenpandya, hdanton, hverkuil+cisco; +Cc: stable
The patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x 0fbd5c2327020858c45b2d1c65775d64cdeca523
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026090930-spry-diving-8f70@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 0fbd5c2327020858c45b2d1c65775d64cdeca523 Mon Sep 17 00:00:00 2001
From: Biren Pandya <birenpandya@gmail.com>
Date: Sun, 21 Jun 2026 10:04:37 +0530
Subject: [PATCH] media: cec: disable delayed work before freeing an
interrupted transmit
cec_transmit_msg_fh() drops adap->lock to wait for a blocking transmit in
wait_for_completion_killable(). If that wait is interrupted by a signal,
cancel_delayed_work_sync() can run before the CEC kthread arms the reply
timeout via schedule_delayed_work(&data->work) in cec_transmit_done_ts().
The work is then armed after the cancel, and the data is freed with its
delayed_work still pending:
ODEBUG: free active (active state 0) object: ... hint: cec_wait_timeout
Use disable_delayed_work_sync(): it cancels the work and disables it, so
the later schedule_delayed_work() becomes a no-op and the work cannot be
re-armed. The data is freed right after, so it need not be re-enabled.
Fixes: 490d84f6d73c ("media: cec: forgot to cancel delayed work")
Reported-by: syzbot+051024d603432b4ab395@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=051024d603432b4ab395
Suggested-by: Hillf Danton <hdanton@sina.com>
Cc: stable@vger.kernel.org
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
diff --git a/drivers/media/cec/core/cec-adap.c b/drivers/media/cec/core/cec-adap.c
index a90cb84a4b4d..829ee4861bf7 100644
--- a/drivers/media/cec/core/cec-adap.c
+++ b/drivers/media/cec/core/cec-adap.c
@@ -965,7 +965,7 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
*/
mutex_unlock(&adap->lock);
err = wait_for_completion_killable(&data->c);
- cancel_delayed_work_sync(&data->work);
+ disable_delayed_work_sync(&data->work);
mutex_lock(&adap->lock);
if (err)
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 6.6.y] media: cec: disable delayed work before freeing an interrupted transmit
2026-09-09 10:58 FAILED: patch "[PATCH] media: cec: disable delayed work before freeing an" failed to apply to 6.6-stable tree gregkh
@ 2026-11-29 15:27 ` Dickson Wu via B4 Relay
0 siblings, 0 replies; 4+ messages in thread
From: Dickson Wu @ 2026-11-29 15:27 UTC (permalink / raw)
To: stable; +Cc: hdanton, birenpandya, hverkuil+cisco, linux-media
From: Biren Pandya <birenpandya@gmail.com>
commit 0fbd5c2327020858c45b2d1c65775d64cdeca523 upstream.
cec_transmit_msg_fh() drops adap->lock to wait for a blocking transmit in
wait_for_completion_killable(). If that wait is interrupted by a signal,
cancel_delayed_work_sync() can run before the CEC kthread arms the reply
timeout via schedule_delayed_work(&data->work) in cec_transmit_done_ts().
The work is then armed after the cancel, and the data is freed with its
delayed_work still pending:
ODEBUG: free active (active state 0) object: ... hint: cec_wait_timeout
Use disable_delayed_work_sync(): it cancels the work and disables it, so
the later schedule_delayed_work() becomes a no-op and the work cannot be
re-armed. The data is freed right after, so it need not be re-enabled.
Fixes: 490d84f6d73c ("media: cec: forgot to cancel delayed work")
Reported-by: syzbot+051024d603432b4ab395@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=051024d603432b4ab395
Suggested-by: Hillf Danton <hdanton@sina.com>
Cc: stable@vger.kernel.org
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
[ adapted to 6.6.y: detach blocked transmit before draining timeout ]
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
---
6.6 has no disable_delayed_work_sync(), so the waiter can't stop the
timeout work from being re-armed. Instead it drains the work only after
cec_data_cancel() has taken the transmit off the adapter, when nothing
can schedule it again, and cec_received_msg_ts() leaves that drain to
the blocking waiter. list_del() becomes list_del_init() so a late
cec_wait_timeout() sees an empty list and returns.
Tested on v6.6.163: W=1 build of drivers/media/cec/core/cec-adap.o,
base vs patched with the same config, no new warnings. Both kernels
booted in a KVM guest with vivid and registered two CEC devices. I
didn't reproduce the interrupted-transmit race itself.
The backport and the test runs were prepared with AI coding tools
(OpenAI Codex agents, with review by Claude). I went over the result
before signing off.
---
drivers/media/cec/core/cec-adap.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/media/cec/core/cec-adap.c b/drivers/media/cec/core/cec-adap.c
index 6bd1dbf0e24a..863fd200e4cd 100644
--- a/drivers/media/cec/core/cec-adap.c
+++ b/drivers/media/cec/core/cec-adap.c
@@ -919,7 +919,6 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
*/
mutex_unlock(&adap->lock);
err = wait_for_completion_killable(&data->c);
- cancel_delayed_work_sync(&data->work);
mutex_lock(&adap->lock);
if (err)
@@ -936,9 +935,12 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
/* The transmit completed (possibly with an error) */
*msg = data->msg;
if (WARN_ON(!list_empty(&data->list)))
- list_del(&data->list);
+ list_del_init(&data->list);
if (WARN_ON(!list_empty(&data->xfer_list)))
- list_del(&data->xfer_list);
+ list_del_init(&data->xfer_list);
+ mutex_unlock(&adap->lock);
+ cancel_delayed_work_sync(&data->work);
+ mutex_lock(&adap->lock);
kfree(data);
return 0;
}
@@ -1211,7 +1213,7 @@ void cec_received_msg_ts(struct cec_adapter *adap,
list_del_init(&data->list);
/* Cancel the pending timeout work */
- if (!cancel_delayed_work(&data->work)) {
+ if (!cancel_delayed_work(&data->work) && !data->blocking) {
mutex_unlock(&adap->lock);
cancel_delayed_work_sync(&data->work);
mutex_lock(&adap->lock);
---
base-commit: e2bb30811e063ce0db964484357973b855b06572
change-id: 20261129-cec-xmit-66-afeb939f8148
Best regards,
--
Dickson Wu <dickson.wu@certik.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 6.6.y] media: cec: disable delayed work before freeing an interrupted transmit
@ 2026-11-29 15:27 ` Dickson Wu via B4 Relay
0 siblings, 0 replies; 4+ messages in thread
From: Dickson Wu via B4 Relay @ 2026-11-29 15:27 UTC (permalink / raw)
To: stable; +Cc: hdanton, birenpandya, hverkuil+cisco, linux-media
From: Biren Pandya <birenpandya@gmail.com>
commit 0fbd5c2327020858c45b2d1c65775d64cdeca523 upstream.
cec_transmit_msg_fh() drops adap->lock to wait for a blocking transmit in
wait_for_completion_killable(). If that wait is interrupted by a signal,
cancel_delayed_work_sync() can run before the CEC kthread arms the reply
timeout via schedule_delayed_work(&data->work) in cec_transmit_done_ts().
The work is then armed after the cancel, and the data is freed with its
delayed_work still pending:
ODEBUG: free active (active state 0) object: ... hint: cec_wait_timeout
Use disable_delayed_work_sync(): it cancels the work and disables it, so
the later schedule_delayed_work() becomes a no-op and the work cannot be
re-armed. The data is freed right after, so it need not be re-enabled.
Fixes: 490d84f6d73c ("media: cec: forgot to cancel delayed work")
Reported-by: syzbot+051024d603432b4ab395@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=051024d603432b4ab395
Suggested-by: Hillf Danton <hdanton@sina.com>
Cc: stable@vger.kernel.org
Signed-off-by: Biren Pandya <birenpandya@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
[ adapted to 6.6.y: detach blocked transmit before draining timeout ]
Signed-off-by: Dickson Wu <dickson.wu@certik.com>
---
6.6 has no disable_delayed_work_sync(), so the waiter can't stop the
timeout work from being re-armed. Instead it drains the work only after
cec_data_cancel() has taken the transmit off the adapter, when nothing
can schedule it again, and cec_received_msg_ts() leaves that drain to
the blocking waiter. list_del() becomes list_del_init() so a late
cec_wait_timeout() sees an empty list and returns.
Tested on v6.6.163: W=1 build of drivers/media/cec/core/cec-adap.o,
base vs patched with the same config, no new warnings. Both kernels
booted in a KVM guest with vivid and registered two CEC devices. I
didn't reproduce the interrupted-transmit race itself.
The backport and the test runs were prepared with AI coding tools
(OpenAI Codex agents, with review by Claude). I went over the result
before signing off.
---
drivers/media/cec/core/cec-adap.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/media/cec/core/cec-adap.c b/drivers/media/cec/core/cec-adap.c
index 6bd1dbf0e24a..863fd200e4cd 100644
--- a/drivers/media/cec/core/cec-adap.c
+++ b/drivers/media/cec/core/cec-adap.c
@@ -919,7 +919,6 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
*/
mutex_unlock(&adap->lock);
err = wait_for_completion_killable(&data->c);
- cancel_delayed_work_sync(&data->work);
mutex_lock(&adap->lock);
if (err)
@@ -936,9 +935,12 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
/* The transmit completed (possibly with an error) */
*msg = data->msg;
if (WARN_ON(!list_empty(&data->list)))
- list_del(&data->list);
+ list_del_init(&data->list);
if (WARN_ON(!list_empty(&data->xfer_list)))
- list_del(&data->xfer_list);
+ list_del_init(&data->xfer_list);
+ mutex_unlock(&adap->lock);
+ cancel_delayed_work_sync(&data->work);
+ mutex_lock(&adap->lock);
kfree(data);
return 0;
}
@@ -1211,7 +1213,7 @@ void cec_received_msg_ts(struct cec_adapter *adap,
list_del_init(&data->list);
/* Cancel the pending timeout work */
- if (!cancel_delayed_work(&data->work)) {
+ if (!cancel_delayed_work(&data->work) && !data->blocking) {
mutex_unlock(&adap->lock);
cancel_delayed_work_sync(&data->work);
mutex_lock(&adap->lock);
---
base-commit: e2bb30811e063ce0db964484357973b855b06572
change-id: 20261129-cec-xmit-66-afeb939f8148
Best regards,
--
Dickson Wu <dickson.wu@certik.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 6.6.y] media: cec: disable delayed work before freeing an interrupted transmit
2026-11-29 15:27 ` Dickson Wu via B4 Relay
(?)
@ 2026-12-02 13:48 ` Sasha Levin
-1 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2026-12-02 13:48 UTC (permalink / raw)
To: stable
Cc: Sasha Levin, hdanton, birenpandya, hverkuil+cisco, linux-media,
Dickson Wu via B4 Relay, Dickson Wu
> [ adapted to 6.6.y: detach blocked transmit before draining timeout ]
Queued for 6.6, thanks.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-02 13:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-09 10:58 FAILED: patch "[PATCH] media: cec: disable delayed work before freeing an" failed to apply to 6.6-stable tree gregkh
2026-11-29 15:27 ` [PATCH 6.6.y] media: cec: disable delayed work before freeing an interrupted transmit Dickson Wu
2026-11-29 15:27 ` Dickson Wu via B4 Relay
2026-12-02 13:48 ` Sasha Levin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.