All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tracing: Uninitialized variable in create_tracing_map_fields()
@ 2018-03-28 11:48 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2018-03-28 11:48 UTC (permalink / raw)
  To: Steven Rostedt, Tom Zanussi; +Cc: Ingo Molnar, linux-kernel, kernel-janitors

Smatch complains that idx can be used uninitialized when we check if
(idx < 0).  It has to be the first iteration through the loop and the
HIST_FIELD_FL_STACKTRACE bit has to be clear and the HIST_FIELD_FL_VAR
bit has to be set to reach the bug.

Fixes: 30350d65ac56 ("tracing: Add variable support to hist triggers")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 4f027642ceef..6aceee287d07 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -4411,7 +4411,7 @@ static int create_tracing_map_fields(struct hist_trigger_data *hist_data)
 	struct tracing_map *map = hist_data->map;
 	struct ftrace_event_field *field;
 	struct hist_field *hist_field;
-	int i, idx;
+	int i, idx = 0;
 
 	for_each_hist_field(i, hist_data) {
 		hist_field = hist_data->fields[i];

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] tracing: Uninitialized variable in create_tracing_map_fields()
@ 2018-03-28 11:48 ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2018-03-28 11:48 UTC (permalink / raw)
  To: Steven Rostedt, Tom Zanussi; +Cc: Ingo Molnar, linux-kernel, kernel-janitors

Smatch complains that idx can be used uninitialized when we check if
(idx < 0).  It has to be the first iteration through the loop and the
HIST_FIELD_FL_STACKTRACE bit has to be clear and the HIST_FIELD_FL_VAR
bit has to be set to reach the bug.

Fixes: 30350d65ac56 ("tracing: Add variable support to hist triggers")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 4f027642ceef..6aceee287d07 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -4411,7 +4411,7 @@ static int create_tracing_map_fields(struct hist_trigger_data *hist_data)
 	struct tracing_map *map = hist_data->map;
 	struct ftrace_event_field *field;
 	struct hist_field *hist_field;
-	int i, idx;
+	int i, idx = 0;
 
 	for_each_hist_field(i, hist_data) {
 		hist_field = hist_data->fields[i];

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] tracing: Uninitialized variable in create_tracing_map_fields()
  2018-03-28 11:48 ` Dan Carpenter
@ 2018-03-28 14:04   ` Tom Zanussi
  -1 siblings, 0 replies; 6+ messages in thread
From: Tom Zanussi @ 2018-03-28 14:04 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Steven Rostedt, Ingo Molnar, linux-kernel, kernel-janitors

Hi Dan,

On Wed, 2018-03-28 at 14:48 +0300, Dan Carpenter wrote:
> Smatch complains that idx can be used uninitialized when we check if
> (idx < 0).  It has to be the first iteration through the loop and the
> HIST_FIELD_FL_STACKTRACE bit has to be clear and the HIST_FIELD_FL_VAR
> bit has to be set to reach the bug.
> 
> Fixes: 30350d65ac56 ("tracing: Add variable support to hist triggers")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index 4f027642ceef..6aceee287d07 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -4411,7 +4411,7 @@ static int create_tracing_map_fields(struct hist_trigger_data *hist_data)
>  	struct tracing_map *map = hist_data->map;
>  	struct ftrace_event_field *field;
>  	struct hist_field *hist_field;
> -	int i, idx;
> +	int i, idx = 0;
>  
>  	for_each_hist_field(i, hist_data) {
>  		hist_field = hist_data->fields[i];

Yes, this should definitely be initialized to 0, thanks for the patch!

Acked-by: Tom Zanussi <tom.zanussi@linux.intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] tracing: Uninitialized variable in create_tracing_map_fields()
@ 2018-03-28 14:04   ` Tom Zanussi
  0 siblings, 0 replies; 6+ messages in thread
From: Tom Zanussi @ 2018-03-28 14:04 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Steven Rostedt, Ingo Molnar, linux-kernel, kernel-janitors

Hi Dan,

On Wed, 2018-03-28 at 14:48 +0300, Dan Carpenter wrote:
> Smatch complains that idx can be used uninitialized when we check if
> (idx < 0).  It has to be the first iteration through the loop and the
> HIST_FIELD_FL_STACKTRACE bit has to be clear and the HIST_FIELD_FL_VAR
> bit has to be set to reach the bug.
> 
> Fixes: 30350d65ac56 ("tracing: Add variable support to hist triggers")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index 4f027642ceef..6aceee287d07 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -4411,7 +4411,7 @@ static int create_tracing_map_fields(struct hist_trigger_data *hist_data)
>  	struct tracing_map *map = hist_data->map;
>  	struct ftrace_event_field *field;
>  	struct hist_field *hist_field;
> -	int i, idx;
> +	int i, idx = 0;
>  
>  	for_each_hist_field(i, hist_data) {
>  		hist_field = hist_data->fields[i];

Yes, this should definitely be initialized to 0, thanks for the patch!

Acked-by: Tom Zanussi <tom.zanussi@linux.intel.com>



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] tracing: Uninitialized variable in create_tracing_map_fields()
  2018-03-28 14:04   ` Tom Zanussi
@ 2018-04-02 15:52     ` Steven Rostedt
  -1 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2018-04-02 15:52 UTC (permalink / raw)
  To: Tom Zanussi; +Cc: Dan Carpenter, Ingo Molnar, linux-kernel, kernel-janitors

On Wed, 28 Mar 2018 09:04:40 -0500
Tom Zanussi <tom.zanussi@linux.intel.com> wrote:

> Yes, this should definitely be initialized to 0, thanks for the patch!
> 
> Acked-by: Tom Zanussi <tom.zanussi@linux.intel.com>

Thanks, I applied it and will push to git after it has succeeded in
testing.

-- Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] tracing: Uninitialized variable in create_tracing_map_fields()
@ 2018-04-02 15:52     ` Steven Rostedt
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Rostedt @ 2018-04-02 15:52 UTC (permalink / raw)
  To: Tom Zanussi; +Cc: Dan Carpenter, Ingo Molnar, linux-kernel, kernel-janitors

On Wed, 28 Mar 2018 09:04:40 -0500
Tom Zanussi <tom.zanussi@linux.intel.com> wrote:

> Yes, this should definitely be initialized to 0, thanks for the patch!
> 
> Acked-by: Tom Zanussi <tom.zanussi@linux.intel.com>

Thanks, I applied it and will push to git after it has succeeded in
testing.

-- Steve

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-04-02 15:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-28 11:48 [PATCH] tracing: Uninitialized variable in create_tracing_map_fields() Dan Carpenter
2018-03-28 11:48 ` Dan Carpenter
2018-03-28 14:04 ` Tom Zanussi
2018-03-28 14:04   ` Tom Zanussi
2018-04-02 15:52   ` Steven Rostedt
2018-04-02 15:52     ` Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.