[pulseaudio-discuss] [PATCH 1/2] memblock: Detect block ID collisions in pa_memimport_get
Peter Meerwald
pmeerw at pmeerw.net
Fri Dec 5 03:51:06 PST 2014
> Make sure we don't hand out the wrong block, in case we have the
> same block ID in different SHM segments.
this adds two checks: for block type and that the shm id matches
using %u in pa_log() would save the (int) casts; maybe both, shm_id and
memory.id could be logged?
thanks, p.
> Signed-off-by: David Henningsson <david.henningsson at canonical.com>
> ---
> src/pulsecore/memblock.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/src/pulsecore/memblock.c b/src/pulsecore/memblock.c
> index f8b008f..ca24dec 100644
> --- a/src/pulsecore/memblock.c
> +++ b/src/pulsecore/memblock.c
> @@ -1017,6 +1017,11 @@ pa_memblock* pa_memimport_get(pa_memimport *i, uint32_t block_id, uint32_t shm_i
> pa_mutex_lock(i->mutex);
>
> if ((b = pa_hashmap_get(i->blocks, PA_UINT32_TO_PTR(block_id)))) {
> + if (b->type != PA_MEMBLOCK_IMPORTED || b->per_type.imported.segment->memory.id != shm_id) {
> + pa_log("Cannot import memory due to to block ID collision (block %d, shm id %d)!", (int) block_id, (int) shm_id);
> + b = NULL;
> + goto finish;
> + }
> pa_memblock_ref(b);
> goto finish;
> }
>
--
Peter Meerwald
+43-664-2444418 (mobile)
More information about the pulseaudio-discuss
mailing list