- switch (event_param->instrumentation) {
- default:
- event_fd = lttng_get_unused_fd();
- if (event_fd < 0) {
- ret = event_fd;
- goto fd_error;
- }
- event_file = anon_inode_getfile("[lttng_event]",
- <tng_event_fops,
- NULL, O_RDWR);
- if (IS_ERR(event_file)) {
- ret = PTR_ERR(event_file);
- goto file_error;
- }
- if (event_param->instrumentation == LTTNG_KERNEL_TRACEPOINT) {
- struct lttng_enabler *enabler;
-
- if (event_param->name[strlen(event_param->name) - 1] == '*') {
- enabler = lttng_enabler_create(LTTNG_ENABLER_WILDCARD,
- event_param, channel);
- } else {
- enabler = lttng_enabler_create(LTTNG_ENABLER_NAME,
- event_param, channel);
- }
- priv = enabler;
+ event_fd = lttng_get_unused_fd();
+ if (event_fd < 0) {
+ ret = event_fd;
+ goto fd_error;
+ }
+ event_file = anon_inode_getfile("[lttng_event]",
+ <tng_event_fops,
+ NULL, O_RDWR);
+ if (IS_ERR(event_file)) {
+ ret = PTR_ERR(event_file);
+ goto file_error;
+ }
+ /* The event holds a reference on the channel */
+ if (!atomic_long_add_unless(&channel_file->f_count, 1, LONG_MAX)) {
+ ret = -EOVERFLOW;
+ goto refcount_error;
+ }
+ if (event_param->instrumentation == LTTNG_KERNEL_TRACEPOINT
+ || event_param->instrumentation == LTTNG_KERNEL_SYSCALL) {
+ struct lttng_enabler *enabler;
+
+ if (event_param->name[strlen(event_param->name) - 1] == '*') {
+ enabler = lttng_enabler_create(LTTNG_ENABLER_WILDCARD,
+ event_param, channel);