Skip to content

Commit

Permalink
media: rc: ensure that uevent can be read directly after rc device re…
Browse files Browse the repository at this point in the history
…gister

commit 896111d 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: a2e2d73 ("media: rc: do not access device via sysfs after rc_unregister_device()")
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
seanyoung authored and gregkh committed Feb 3, 2021
1 parent ce9e154 commit b3b75f8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/media/rc/rc-main.c
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit b3b75f8

Please sign in to comment.