OSDN Git Service

media: cec-core: first mark device unregistered, then wake up fhs
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 9 Oct 2020 09:16:16 +0000 (11:16 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 16 Nov 2020 09:31:09 +0000 (10:31 +0100)
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>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/cec/core/cec-core.c

index ece2362..551689d 100644 (file)
@@ -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);