Fix: metadata stream leak, missing list removal and locking
[lttng-modules.git] / src / lttng-abi.c
index c3721b93e428ce7d48bf94f40ff9ebd0a6585ef4..4dd6e7e5e2fff77290f493664b543e66471b0a96 100644 (file)
@@ -281,6 +281,8 @@ long lttng_abi_add_context(struct file *file,
                return lttng_add_vegid_to_ctx(ctx);
        case LTTNG_KERNEL_CONTEXT_VSGID:
                return lttng_add_vsgid_to_ctx(ctx);
+       case LTTNG_KERNEL_CONTEXT_TIME_NS:
+               return lttng_add_time_ns_to_ctx(ctx);
        default:
                return -EINVAL;
        }
@@ -1090,8 +1092,12 @@ int lttng_metadata_ring_buffer_release(struct inode *inode, struct file *file)
        struct lttng_metadata_stream *stream = file->private_data;
        struct lib_ring_buffer *buf = stream->priv;
 
+       mutex_lock(&stream->metadata_cache->lock);
+       list_del(&stream->list);
+       mutex_unlock(&stream->metadata_cache->lock);
        kref_put(&stream->metadata_cache->refcount, metadata_cache_destroy);
        module_put(stream->transport->owner);
+       kfree(stream);
        return lib_ring_buffer_release(inode, file, buf);
 }
 
@@ -1243,8 +1249,10 @@ int lttng_abi_open_metadata_stream(struct file *channel_file)
        if (ret < 0)
                goto fd_error;
 
+       mutex_lock(&session->metadata_cache->lock);
        list_add(&metadata_stream->list,
                &session->metadata_cache->metadata_stream);
+       mutex_unlock(&session->metadata_cache->lock);
        return ret;
 
 fd_error:
This page took 0.023074 seconds and 4 git commands to generate.