Fix: refuse overwrite mode buffers with less than two subbuffers
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 23 May 2014 13:26:11 +0000 (09:26 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 23 May 2014 13:27:37 +0000 (09:27 -0400)
Fixes #793

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lib/ringbuffer/ring_buffer_backend.c

index 8e1a796a55071abb6f388b2c9ed11cc34b7ed845..75bed8179da85684c57709aeeab63790602c1cd9 100644 (file)
@@ -331,6 +331,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)
This page took 0.026241 seconds and 4 git commands to generate.