From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail3-164.sinamail.sina.com.cn (mail3-164.sinamail.sina.com.cn [202.108.3.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DA1B1DF73A for ; Sat, 20 Jun 2026 23:35:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.108.3.164 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781998521; cv=none; b=VgqcVQ27ryi6VQLIPml4EtkJ/cS4af+alczU/a9sFyQYQjfL9Z7j6dJ3SRwM2WDI/ZCs6Cii75CjHWkHT0wkBYrs6hh7TO9wr0/FzMKbRH3mUkbTPZjxlztlR4pzoE6gLdnHlbDqxLhi3Gep13dZTq1hwvZG/kqp5vdhwRiK3WE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781998521; c=relaxed/simple; bh=kKV8fkzZ4NKoeJeZz9dLwYSPWbjxm2yHtlqJf2/k/WY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FfTH3zSX+NunSt6I0OH9YVay2mj56eE/ak9lzFVVlUmMG5JIHGLdfrIwIsx9H6P0lW/ah+q8s0YWqLhdALwhZYtqx1K/UbjBkY3TOoXjKrX0WzdYfwUwnSux+OsWeVc+fRGGYA0z+30sjUnY/ygaaOOITg3k2MzA+Bm9tTbNO2M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b=WHfLTK6T; arc=none smtp.client-ip=202.108.3.164 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=sina.com header.i=@sina.com header.b="WHfLTK6T" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sina.com; s=201208; t=1781998517; bh=O9E+7l5IFXu4RTVOsMeyI74AIwZ45KAzj5owUSypf/o=; h=From:Subject:Date:Message-ID; b=WHfLTK6T2q1c2NshYkGJjid0MhuCsukfyorlcCOjRUfiR9NB/hNZW5azYdFBQh8xI MtiGeuZ5HEH3thV5Hq7pWb5WgBXsoUYBWGklwR/FDe9q7WOufBnpokdMvI/uSlIUwN LMXw+/RIUBs7AfBBkuOoaQI3FSJyhLF+oEML1VMg= X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([114.249.62.144]) by sina.com (10.54.253.32) with ESMTP id 6A3723AA00006036; Sat, 21 Jun 2026 07:35:08 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 4452744456675 X-SMAIL-UIID: 8E960A235EA2424591A5F97B15C162BD-20260621-073508-1 From: Hillf Danton To: Biren Pandya Cc: Hans Verkuil , Mauro Carvalho Chehab , Kees Cook , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, syzbot+051024d603432b4ab395@syzkaller.appspotmail.com Subject: Re: [PATCH] media: cec: cancel delayed work before freeing an interrupted transmit Date: Sun, 21 Jun 2026 07:34:54 +0800 Message-ID: <20260620233457.1923-1-hdanton@sina.com> In-Reply-To: <20260620191515.50238-2-birenpandya@gmail.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Sun, 21 Jun 2026 00:45:13 +0530 Biren Pandya wrote: > If wait_for_completion_killable() is interrupted in cec_transmit_msg_fh(), > the previous cancel_delayed_work_sync() could race with the CEC kthread, > which might re-arm the timeout *after* the cancel completes. This leads > to freeing active delayed_work and an ODEBUG warning. > Given no specifying how it is armed again after cancel, re-arm in general is handled by disabling the work item before cancel. > Fix this by cancelling the delayed work only after removing the data from > the transmit and wait queues, ensuring the kthread cannot re-arm it. Drop > adap->lock around the synchronous cancel to avoid deadlocking with > cec_wait_timeout(). > > Fixes: 490d84f6d73c ("media: cec: forgot to cancel delayed work") > Reported-by: syzbot+051024d603432b4ab395@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=051024d603432b4ab395 > Signed-off-by: Biren Pandya > --- > 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 8f7244ac1d43..50bd8bbeb5a5 100644 > --- a/drivers/media/cec/core/cec-adap.c > +++ b/drivers/media/cec/core/cec-adap.c > @@ -965,7 +965,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) > @@ -985,6 +984,13 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg, > list_del(&data->list); > if (WARN_ON(!list_empty(&data->xfer_list))) > list_del(&data->xfer_list); > + > + if (!cancel_delayed_work(&data->work)) { > + mutex_unlock(&adap->lock); > + cancel_delayed_work_sync(&data->work); > + mutex_lock(&adap->lock); > + } > + > kfree(data); > return 0; > } > -- > 2.50.1