Skip to contentSkip to conversation

media: rc: ensure that uevent can be read directly after rc device register

git:media_tree/fixes Mauro Carvalho Chehab 1 participant 1 message Jan 4, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

This is an automatic generated email to let you know that the following patch were queued:

Subject: media: rc: ensure that uevent can be read directly after rc device register
Author:  Sean Young <[email protected]>
Date:    Sun Dec 20 13:29:54 2020 +0100

There is a race condition where if the /sys/class/rc0/uevent file is read before rc_dev->registered is set to true, -ENODEV will be returned.

Fixes a2e2d73fa281 ("media: rc: do not access device via sysfs after rc_unregister_device()")
 drivers/media/rc/rc-main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

---

drivers/media/rc/rc-main.c +2 -2
index 1d811e5ffb55..29d4d01896ff 100644
@@ -1928,6 +1928,8 @@ int rc_register_device(struct rc_dev *dev)
 			goto out_raw;
 	}
 
+	dev->registered = true;
+
 	rc = device_add(&dev->dev);
 	if (rc)
 		goto out_rx_free;
@@ -1937,8 +1939,6 @@ int rc_register_device(struct rc_dev *dev)
 		 dev->device_name ?: "Unspecified device", path ?: "N/A");
 	kfree(path);
 
-	dev->registered = true;
-
 	/*
 	 * once the the input device is registered in rc_setup_rx_device,
 	 * userspace can open the input device and rc_open() will be called