2018-03-23 11:38:58

by Dan Carpenter

[permalink] [raw]
Subject: [PATCH] tracing: Fix a potential NULL dereference

We forgot to set the error code on this path so we return ERR_PTR(0)
which is NULL. It results in a NULL dereference in the caller.

Fixes: 100719dcef44 ("tracing: Add simple expression support to hist triggers")
Signed-off-by: Dan Carpenter <[email protected]>

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 4f027642ceef..a02bc09d765a 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -2776,6 +2776,7 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
expr->fn = hist_field_plus;
break;
default:
+ ret = -EINVAL;
goto free;
}



2018-03-23 13:24:40

by Tom Zanussi

[permalink] [raw]
Subject: Re: [PATCH] tracing: Fix a potential NULL dereference

Hi Dan,

On Fri, 2018-03-23 at 14:37 +0300, Dan Carpenter wrote:
> We forgot to set the error code on this path so we return ERR_PTR(0)
> which is NULL. It results in a NULL dereference in the caller.
>
> Fixes: 100719dcef44 ("tracing: Add simple expression support to hist triggers")
> Signed-off-by: Dan Carpenter <[email protected]>
>
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index 4f027642ceef..a02bc09d765a 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -2776,6 +2776,7 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data,
> expr->fn = hist_field_plus;
> break;
> default:
> + ret = -EINVAL;
> goto free;
> }
>

Acked-by: Tom Zanussi <[email protected]>

Thanks for catching this!

Tom


2018-03-23 15:16:43

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] tracing: Fix a potential NULL dereference

On Fri, 23 Mar 2018 08:23:13 -0500
Tom Zanussi <[email protected]> wrote:


> Acked-by: Tom Zanussi <[email protected]>
>
> Thanks for catching this!


Thanks Dan, applied.

-- Steve