summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2019-05-10 18:15:04 +0300
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>2019-05-22 22:33:57 +0300
commit354cf00339b12da6e685770e9e411ebe05d3e3a3 (patch)
tree3ab8292f7ca80b22a6f159ef63f59b47baf28615
parent9390467c2d3bd19778ec23b39dde5424151ec37d (diff)
downloadlinux-354cf00339b12da6e685770e9e411ebe05d3e3a3.tar.xz
media: cec: mark devnode as registered before actually registering it
The cec device node can be used right after it was created, but that leaves a race condition where the device was created, but devnode->registered was still false. So an ioctl() would result in an error. So set it to true before calling cdev_device_add() and to false again if cdev_device_add returned an error. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
-rw-r--r--drivers/media/cec/cec-core.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/media/cec/cec-core.c b/drivers/media/cec/cec-core.c
index f5d1578e256a..db7adffcdc76 100644
--- a/drivers/media/cec/cec-core.c
+++ b/drivers/media/cec/cec-core.c
@@ -128,13 +128,14 @@ static int __must_check cec_devnode_register(struct cec_devnode *devnode,
devnode->cdev.owner = owner;
kobject_set_name(&devnode->cdev.kobj, "cec%d", devnode->minor);
+ devnode->registered = true;
ret = cdev_device_add(&devnode->cdev, &devnode->dev);
if (ret) {
+ devnode->registered = false;
pr_err("%s: cdev_device_add failed\n", __func__);
goto clr_bit;
}
- devnode->registered = true;
return 0;
clr_bit: