Re: [PATCH 03/11] kernel-shark-qt: Avoid race condition in kshark_get_event_name_easy()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 21 Nov 2018 15:14:21 +0000
Yordan Karadzhov <ykaradzhov@xxxxxxxxxx> wrote:

> Calling tep_data_event_from_type() is not thread-safe (potential
> race condition). This patch protects the access to it by using the
> mutex associated with the input file.

Tzvetomir sent patches to handle the race condition here. I'll work to
apply his.

-- Steve

> 
> Signed-off-by: Yordan Karadzhov <ykaradzhov@xxxxxxxxxx>
> ---
>  kernel-shark-qt/src/libkshark.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/kernel-shark-qt/src/libkshark.c b/kernel-shark-qt/src/libkshark.c
> index fa85171..89ae769 100644
> --- a/kernel-shark-qt/src/libkshark.c
> +++ b/kernel-shark-qt/src/libkshark.c
> @@ -1147,7 +1147,18 @@ const char *kshark_get_event_name_easy(struct kshark_entry *entry)
>  		}
>  	}
>  
> +	/*
> +	 * Calling tep_data_event_from_type() is not thread-safe (potential
> +	 * race condition).
> +	 * TODO: See if we can add a thread-safe version of the
> +	 * function. For the time being use a mutex to protect the access.
> +	 */
> +	pthread_mutex_lock(&kshark_ctx->input_mutex);
> +
>  	event = tep_data_event_from_type(kshark_ctx->pevent, event_id);
> +
> +	pthread_mutex_unlock(&kshark_ctx->input_mutex);
> +
>  	if (event)
>  		return event->name;
>  




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux