[pulseaudio-commits] 4 commits - src/pulse src/pulsecore

Peter Meerwald pmeerw at kemper.freedesktop.org
Mon Aug 18 14:28:09 PDT 2014


 src/pulse/context.c             |   14 +++++++++++---
 src/pulsecore/protocol-native.c |    6 +++++-
 src/pulsecore/srbchannel.c      |   20 ++++++++++++++++++++
 3 files changed, 36 insertions(+), 4 deletions(-)

New commits:
commit 096c8903a95beb1a303be4d79c8ed8e873fe5197
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Mon Aug 18 16:55:01 2014 +0200

    context: Handle client-side failure of pa_srbchannel_new_from_template()
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
    Cc: David Henningsson <david.henningsson at canonical.com>

diff --git a/src/pulse/context.c b/src/pulse/context.c
index 387306c..d572406 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -365,6 +365,10 @@ static void handle_srbchannel_memblock(pa_context *c, pa_memblock *memblock) {
     c->srb_template.memblock = memblock;
     pa_memblock_ref(memblock);
     sr = pa_srbchannel_new_from_template(c->mainloop, &c->srb_template);
+    if (!sr) {
+        pa_context_fail(c, PA_ERR_PROTOCOL);
+        return;
+    }
 
     /* Ack the enable command */
     t = pa_tagstruct_new(NULL, 0);

commit fc0447ce8806bff1484b01f217e4366da87a6d9b
Author: Peter Meerwald <p.meerwald at bct-electronic.com>
Date:   Mon Aug 18 17:02:40 2014 +0200

    context: Stop and return if srbchannel memblock looks fishy
    
    handle_srbchannel_memblock() should return when memblock sanity checks fail
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
    Cc: David Henningsson <david.henningsson at canonical.com>

diff --git a/src/pulse/context.c b/src/pulse/context.c
index db89b58..387306c 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -350,12 +350,16 @@ static void handle_srbchannel_memblock(pa_context *c, pa_memblock *memblock) {
     pa_assert(c);
 
     /* Memblock sanity check */
-    if (!memblock)
+    if (!memblock) {
         pa_context_fail(c, PA_ERR_PROTOCOL);
-    else if (pa_memblock_is_read_only(memblock))
+        return;
+    } else if (pa_memblock_is_read_only(memblock)) {
         pa_context_fail(c, PA_ERR_PROTOCOL);
-    else if (pa_memblock_is_ours(memblock))
+        return;
+    } else if (pa_memblock_is_ours(memblock)) {
         pa_context_fail(c, PA_ERR_PROTOCOL);
+        return;
+    }
 
     /* Create the srbchannel */
     c->srb_template.memblock = memblock;

commit fd193273271af5cc3e15c7b2c89dbd03704393ae
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Tue Aug 12 23:33:12 2014 +0200

    srbchannel: pa_srbchannel_new() may fail
    
    return from setup_srbchannel() when pa_srbchannel_new() fails
    
    pa_srbchannel_new() depends on HAVE_SYS_EVENTFD_H, e.g. Debian/kFreeBSD doesn't
    have it
    
    Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
    Acked-by: David Henningsson <david.henningsson at canonical.com>

diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 5f2c35d..93db157 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -2612,8 +2612,12 @@ static void setup_srbchannel(pa_native_connection *c) {
         return;
     }
 
-    pa_log_debug("Enabling srbchannel...");
     srb = pa_srbchannel_new(c->protocol->core->mainloop, c->protocol->core->rw_mempool);
+    if (!srb) {
+        pa_log_debug("Failed to create srbchannel");
+        return;
+    }
+    pa_log_debug("Enabling srbchannel...");
     pa_srbchannel_export(srb, &srbt);
 
     /* Send enable command to client */

commit 7974a17d1d703f28df16f268f66b3d8cb232e04b
Author: Peter Meerwald <pmeerw at pmeerw.net>
Date:   Tue Aug 12 23:14:13 2014 +0200

    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 at pmeerw.net>
    Cc: David Henningsson <david.henningsson at canonical.com>

diff --git a/src/pulsecore/srbchannel.c b/src/pulsecore/srbchannel.c
index 87eeae0..35c86d1 100644
--- a/src/pulsecore/srbchannel.c
+++ b/src/pulsecore/srbchannel.c
@@ -211,7 +211,12 @@ pa_srbchannel* pa_srbchannel_new(pa_mainloop_api *m, pa_mempool *p) {
     sr->rb_write.count = &srh->write_count;
 
     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);
+    if (!sr->sem_write)
+        goto fail;
 
     readfd = pa_fdsem_get(sr->sem_read);
 #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);
 
     return sr;
+
+fail:
+    pa_srbchannel_free(sr);
+
+    return NULL;
 }
 
 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->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);
+    if (!sr->sem_write)
+        goto fail;
 
     pa_srbchannel_swap(sr);
     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);
 
     return sr;
+
+fail:
+    pa_srbchannel_free(sr);
+
+    return NULL;
 }
 
 void pa_srbchannel_export(pa_srbchannel *sr, pa_srbchannel_template *t) {



More information about the pulseaudio-commits mailing list