From 170f31dedc2d526ed006dfb91d57ff0e67ac438f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Thu, 14 Oct 2021 21:05:53 +0200 Subject: [PATCH] pipewire-v4l2: increase reference count atomically The reference count increment in `add_fd_map()` (called from `v4l2_dup()`) may run at the same time as `unref_file()` (called from `v4l2_close()`). Atomically increase the refcnt to avoid any problems. --- pipewire-v4l2/src/pipewire-v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pipewire-v4l2/src/pipewire-v4l2.c b/pipewire-v4l2/src/pipewire-v4l2.c index 42d31028b..83f336931 100644 --- a/pipewire-v4l2/src/pipewire-v4l2.c +++ b/pipewire-v4l2/src/pipewire-v4l2.c @@ -294,7 +294,7 @@ static int add_fd_map(int fd, struct file *file) if (map != NULL) { map->fd = fd; map->file = file; - file->ref++; + ATOMIC_INC(file->ref); } pthread_mutex_unlock(&globals.lock); return 0;