From 8e1ef46e89a86865736a62d2def88f70acb0be55 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 28 Oct 2019 14:52:44 -0400 Subject: [PATCH] consumerd: clean-up: stream attribute accessed without locking stream MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit consumer_metadata_cache_flushed makes use of the metadata stream's ust_metadata_pushed attribute without locking while it is updated by commit_one_metadata_packet() which holds the metadata stream lock. This is marked as a clean-up since the attribute appears to always be accessed while the metadata cache lock is held. However this is a _channel_ attribute and the stream and channel lifetimes do not match, making the locking assumptions conceptually dubious. Signed-off-by: Jérémie Galarneau --- src/common/consumer/consumer-metadata-cache.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/consumer/consumer-metadata-cache.c b/src/common/consumer/consumer-metadata-cache.c index 65702a229..5eee40142 100644 --- a/src/common/consumer/consumer-metadata-cache.c +++ b/src/common/consumer/consumer-metadata-cache.c @@ -273,9 +273,9 @@ int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel, pthread_mutex_lock(&channel->lock); } pthread_mutex_lock(&channel->timer_lock); - pthread_mutex_lock(&channel->metadata_cache->lock); - metadata_stream = channel->metadata_stream; + pthread_mutex_lock(&metadata_stream->lock); + pthread_mutex_lock(&channel->metadata_cache->lock); if (!metadata_stream) { /* @@ -295,6 +295,7 @@ int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel, } pthread_mutex_unlock(&channel->metadata_cache->lock); + pthread_mutex_unlock(&metadata_stream->lock); pthread_mutex_unlock(&channel->timer_lock); if (!timer) { pthread_mutex_unlock(&channel->lock); -- 2.34.1