From: Mathieu Desnoyers Date: Fri, 23 May 2014 13:27:01 +0000 (-0400) Subject: Fix: refuse overwrite mode buffers with less than two subbuffers X-Git-Tag: v2.5.0-rc1~4 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=3d8e9399b2fb9000b3b55e488a7d04184b5bb56e;p=lttng-ust.git Fix: refuse overwrite mode buffers with less than two subbuffers Fixes #793 Signed-off-by: Mathieu Desnoyers --- diff --git a/libringbuffer/ring_buffer_backend.c b/libringbuffer/ring_buffer_backend.c index 0d2cc6d0..7d3a3780 100644 --- a/libringbuffer/ring_buffer_backend.c +++ b/libringbuffer/ring_buffer_backend.c @@ -234,6 +234,12 @@ int channel_backend_init(struct channel_backend *chanb, return -EINVAL; if (!num_subbuf || (num_subbuf & (num_subbuf - 1))) return -EINVAL; + /* + * Overwrite mode buffers require at least 2 subbuffers per + * buffer. + */ + if (config->mode == RING_BUFFER_OVERWRITE && num_subbuf < 2) + return -EINVAL; ret = subbuffer_id_check_index(config, num_subbuf); if (ret)