mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	srbchannel: Cleanup when pa_fdsem_open_shm() fails
pa_fdsem_open_shm() returns NULL when HAVE_SYS_EVENTFD_H is #undefined pa_srbchannel_new() and pa_srbchannel_new_from_template() depend on pa_fdsem_open_shm() and shall properly cleanup stuff, and return NULL as well; otherwise, function pa_fdsem_get() will assert: Assertion 'f' failed at pulsecore/fdsem.c:284, function pa_fdsem_get(). Aborting. Debian/kFreeBSD doesn't HAVE_SYS_EVENTFD_H Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Cc: David Henningsson <david.henningsson@canonical.com>
This commit is contained in:
		
							parent
							
								
									dc7ed820ab
								
							
						
					
					
						commit
						7974a17d1d
					
				
					 1 changed files with 20 additions and 0 deletions
				
			
		| 
						 | 
					@ -211,7 +211,12 @@ pa_srbchannel* pa_srbchannel_new(pa_mainloop_api *m, pa_mempool *p) {
 | 
				
			||||||
    sr->rb_write.count = &srh->write_count;
 | 
					    sr->rb_write.count = &srh->write_count;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sr->sem_read = pa_fdsem_new_shm(&srh->read_semdata);
 | 
					    sr->sem_read = pa_fdsem_new_shm(&srh->read_semdata);
 | 
				
			||||||
 | 
					    if (!sr->sem_read)
 | 
				
			||||||
 | 
					        goto fail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sr->sem_write = pa_fdsem_new_shm(&srh->write_semdata);
 | 
					    sr->sem_write = pa_fdsem_new_shm(&srh->write_semdata);
 | 
				
			||||||
 | 
					    if (!sr->sem_write)
 | 
				
			||||||
 | 
					        goto fail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    readfd = pa_fdsem_get(sr->sem_read);
 | 
					    readfd = pa_fdsem_get(sr->sem_read);
 | 
				
			||||||
#ifdef DEBUG_SRBCHANNEL
 | 
					#ifdef DEBUG_SRBCHANNEL
 | 
				
			||||||
| 
						 | 
					@ -221,6 +226,11 @@ pa_srbchannel* pa_srbchannel_new(pa_mainloop_api *m, pa_mempool *p) {
 | 
				
			||||||
    m->io_enable(sr->read_event, PA_IO_EVENT_INPUT);
 | 
					    m->io_enable(sr->read_event, PA_IO_EVENT_INPUT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return sr;
 | 
					    return sr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fail:
 | 
				
			||||||
 | 
					    pa_srbchannel_free(sr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void pa_srbchannel_swap(pa_srbchannel *sr) {
 | 
					static void pa_srbchannel_swap(pa_srbchannel *sr) {
 | 
				
			||||||
| 
						 | 
					@ -249,7 +259,12 @@ pa_srbchannel* pa_srbchannel_new_from_template(pa_mainloop_api *m, pa_srbchannel
 | 
				
			||||||
    sr->rb_write.memory = (uint8_t*) srh + srh->writebuf_offset;
 | 
					    sr->rb_write.memory = (uint8_t*) srh + srh->writebuf_offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sr->sem_read = pa_fdsem_open_shm(&srh->read_semdata, t->readfd);
 | 
					    sr->sem_read = pa_fdsem_open_shm(&srh->read_semdata, t->readfd);
 | 
				
			||||||
 | 
					    if (!sr->sem_read)
 | 
				
			||||||
 | 
					        goto fail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sr->sem_write = pa_fdsem_open_shm(&srh->write_semdata, t->writefd);
 | 
					    sr->sem_write = pa_fdsem_open_shm(&srh->write_semdata, t->writefd);
 | 
				
			||||||
 | 
					    if (!sr->sem_write)
 | 
				
			||||||
 | 
					        goto fail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_srbchannel_swap(sr);
 | 
					    pa_srbchannel_swap(sr);
 | 
				
			||||||
    temp = t->readfd; t->readfd = t->writefd; t->writefd = temp;
 | 
					    temp = t->readfd; t->readfd = t->writefd; t->writefd = temp;
 | 
				
			||||||
| 
						 | 
					@ -261,6 +276,11 @@ pa_srbchannel* pa_srbchannel_new_from_template(pa_mainloop_api *m, pa_srbchannel
 | 
				
			||||||
    m->io_enable(sr->read_event, PA_IO_EVENT_INPUT);
 | 
					    m->io_enable(sr->read_event, PA_IO_EVENT_INPUT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return sr;
 | 
					    return sr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fail:
 | 
				
			||||||
 | 
					    pa_srbchannel_free(sr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void pa_srbchannel_export(pa_srbchannel *sr, pa_srbchannel_template *t) {
 | 
					void pa_srbchannel_export(pa_srbchannel *sr, pa_srbchannel_template *t) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue