return ret;
}
+static int channel_validate(struct lttng_channel *attr)
+{
+ /*
+ * The ringbuffer (both in user space and kernel) behaves badly
+ * in overwrite mode and with less than 2 subbuffers so block it
+ * right away and send back an invalid attribute error.
+ */
+ if (attr->attr.overwrite && attr->attr.num_subbuf < 2) {
+ return -1;
+ }
+ return 0;
+}
+
/*
* Create kernel channel of the kernel session and notify kernel thread.
*/
attr->attr.output = LTTNG_EVENT_MMAP;
}
+ /* Validate common channel properties. */
+ if (channel_validate(attr) < 0) {
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
+
/* Channel not found, creating it */
ret = kernel_create_channel(ksession, attr);
if (ret < 0) {
attr->attr.output = LTTNG_EVENT_MMAP;
}
+ /* Validate common channel properties. */
+ if (channel_validate(attr) < 0) {
+ ret = LTTNG_ERR_INVALID;
+ goto error;
+ }
+
/*
* Validate UST buffer size and number of buffers: must both be power of 2
* and nonzero. We validate right here for UST, because applications will
attr->attr.switch_timer_interval = 0;
}
- /*
- * The ringbuffer (both in user space and kernel) behave badly in overwrite
- * mode and with less than 2 subbuf so block it right away and send back an
- * invalid attribute error.
- */
- if (attr->attr.overwrite && attr->attr.num_subbuf < 2) {
- ret = LTTNG_ERR_INVALID;
- goto error;
- }
-
switch (domain->type) {
case LTTNG_DOMAIN_KERNEL:
{