mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									d21a8caace
								
							
						
					
					
						commit
						170f31dedc
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		| 
						 | 
					@ -294,7 +294,7 @@ static int add_fd_map(int fd, struct file *file)
 | 
				
			||||||
	if (map != NULL) {
 | 
						if (map != NULL) {
 | 
				
			||||||
		map->fd = fd;
 | 
							map->fd = fd;
 | 
				
			||||||
		map->file = file;
 | 
							map->file = file;
 | 
				
			||||||
		file->ref++;
 | 
							ATOMIC_INC(file->ref);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	pthread_mutex_unlock(&globals.lock);
 | 
						pthread_mutex_unlock(&globals.lock);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue