lkml.org 
[lkml]   [2017]   [Nov]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5 15/37] tracing: Add variable support to hist triggers
On Fri, 10 Nov 2017 16:28:41 +0900
Namhyung Kim <namhyung@kernel.org> wrote:

> > + hist_data->attrs->var_defs.expr[n_vars++] = s;
> > +
> > + hist_data->attrs->var_defs.n_vars = n_vars;
> > +
> > + if (n_vars == TRACING_MAP_VARS_MAX)
> > + goto free;
>
> This will silently discard all variables. Why not returning an error?
> Also I think it should be moved to the beginning of this block..

Right, because the check here is already too late. Usually you check
the count before doing the assignment.


if (n_vars == TRACING_MAP_VARS_MAX)
goto free;

hist_data->attrs->var_defs.expr[n_vars++] = s;

Because it is OK for n_vars to equal TRACING_MAP_VARS_MAX, but not OK
to be more.

-- Steve

\
 
 \ /
  Last update: 2017-11-10 14:24    [W:0.066 / U:3.952 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site