From: Sean Young Date: Sun, 20 Dec 2020 12:29:54 +0000 (+0100) Subject: media: rc: ensure that uevent can be read directly after rc device register X-Git-Tag: v5.4.95~54 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b24dc0aa7e9b258e195f9a3af00d8480d1aff655;p=thirdparty%2Fkernel%2Fstable.git media: rc: ensure that uevent can be read directly after rc device register commit 896111dc4bcf887b835b3ef54f48b450d4692a1d upstream. 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. Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1901089 Cc: stable@vger.kernel.org Fixes: a2e2d73fa281 ("media: rc: do not access device via sysfs after rc_unregister_device()") Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index e84f9dccf448a..c4d7e06974d2c 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -1892,6 +1892,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; @@ -1901,8 +1903,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