linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cec-core: first mark device unregistered, then wake up fhs
@ 2020-10-09  9:16 Hans Verkuil
  0 siblings, 0 replies; only message in thread
From: Hans Verkuil @ 2020-10-09  9:16 UTC (permalink / raw)
  To: Linux Media Mailing List

If a CEC device node is unregistered, then it should be marked as
unregistered before waking up any filehandles that are waiting for
an event.

This ensures that there is no race condition where an application can
call CEC_DQEVENT and have the ioctl return 0 instead of ENODEV.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
diff --git a/drivers/media/cec/core/cec-core.c b/drivers/media/cec/core/cec-core.c
index ece236291f35..551689d371a7 100644
--- a/drivers/media/cec/core/cec-core.c
+++ b/drivers/media/cec/core/cec-core.c
@@ -166,12 +166,12 @@ static void cec_devnode_unregister(struct cec_adapter *adap)
 		mutex_unlock(&devnode->lock);
 		return;
 	}
+	devnode->registered = false;
+	devnode->unregistered = true;

 	list_for_each_entry(fh, &devnode->fhs, list)
 		wake_up_interruptible(&fh->wait);

-	devnode->registered = false;
-	devnode->unregistered = true;
 	mutex_unlock(&devnode->lock);

 	mutex_lock(&adap->lock);


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-09  9:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-09  9:16 [PATCH] cec-core: first mark device unregistered, then wake up fhs Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).