aboutsummaryrefslogtreecommitdiff
path: root/drivers/counter/counter-sysfs.c
diff options
context:
space:
mode:
authorDavid Lechner2021-10-17 13:55:21 -0500
committerGreg Kroah-Hartman2021-10-19 11:36:28 +0200
commitf5245a5fdf757f50a6c905fc16cceb1a6146ccf5 (patch)
tree80a651b5444b70ceff26f93d2e97e37cd64c6f7b /drivers/counter/counter-sysfs.c
parentc3ed761c9e1e4987406671b326dab48a048614ee (diff)
counter: drop chrdev_lock
This removes the chrdev_lock from the counter subsystem. This was intended to prevent opening the chrdev more than once. However, this doesn't work in practice since userspace can duplicate file descriptors and pass file descriptors to other processes. Since this protection can't be relied on, it is best to just remove it. Suggested-by: Greg KH <gregkh@linuxfoundation.org> Acked-by: William Breathitt Gray <vilhelm.gray@gmail.com> Signed-off-by: David Lechner <david@lechnology.com> Link: https://lore.kernel.org/r/20211017185521.3468640-1-david@lechnology.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/counter/counter-sysfs.c')
-rw-r--r--drivers/counter/counter-sysfs.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c
index c2fddbb0d442..8c2d7c29ea59 100644
--- a/drivers/counter/counter-sysfs.c
+++ b/drivers/counter/counter-sysfs.c
@@ -796,25 +796,18 @@ static int counter_events_queue_size_write(struct counter_device *counter,
u64 val)
{
DECLARE_KFIFO_PTR(events, struct counter_event);
- int err = 0;
-
- /* Ensure chrdev is not opened more than 1 at a time */
- if (!atomic_add_unless(&counter->chrdev_lock, 1, 1))
- return -EBUSY;
+ int err;
/* Allocate new events queue */
err = kfifo_alloc(&events, val, GFP_KERNEL);
if (err)
- goto exit_early;
+ return err;
/* Swap in new events queue */
kfifo_free(&counter->events);
counter->events.kfifo = events.kfifo;
-exit_early:
- atomic_dec(&counter->chrdev_lock);
-
- return err;
+ return 0;
}
static struct counter_comp counter_num_signals_comp =