Re: [PATCH 1/2] kernel-shark: Initialize the data-related fields of the model

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

 



On Wed, 17 Jul 2019 11:53:05 +0300
"Yordan Karadzhov (VMware)" <y.karadz@xxxxxxxxx> wrote:

> It is particularly important to initialize to zero the "data_size" field
> because its value is used when doing operations like scroll or zoom to
> check if data has been loaded or not. Not having "data_size" set to zero
> can cause segfault (as reported by Steven).
> 
> Reported-By: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204195
> Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@xxxxxxxxx>
> ---
>  kernel-shark/src/libkshark-model.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel-shark/src/libkshark-model.c b/kernel-shark/src/libkshark-model.c
> index 18f9c69..fd4d876 100644
> --- a/kernel-shark/src/libkshark-model.c
> +++ b/kernel-shark/src/libkshark-model.c
> @@ -36,6 +36,9 @@ void ksmodel_init(struct kshark_trace_histo *histo)
>  	 * Initialize an empty histo. The histo will have no bins and will
>  	 * contain no data.
>  	 */
> +	histo->data_size = 0;
> +	histo->data = NULL;
> +
>  	histo->bin_size = 0;
>  	histo->min = 0;
>  	histo->max = 0;

Are we just trying to set all fields of histo to NULL or zero? If so,
why not just do:

	memset(histo, 0, sizeof(*histo));

?

This will make sure ksmodel_init() zeros all of histo when/if we add new
fields.

-- Steve




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

  Powered by Linux