Re: [PATCH 4/4] tracing: add per-subsystem filtering

From: Ingo Molnar
Date: Sun Mar 22 2009 - 15:50:57 EST



* Frederic Weisbecker <fweisbec@xxxxxxxxx> wrote:

> > +int filter_add_subsystem_pred(struct event_subsystem *system,
> > + struct filter_pred *pred)
> > +{
> > + struct ftrace_event_call *call = __start_ftrace_events;
> > + struct filter_pred *event_pred;
> > + int i;
> > +
> > + if (system->preds && !pred->compound)
> > + filter_free_subsystem_preds(system);
> > +
> > + if (!system->preds) {
> > + system->preds = kzalloc(MAX_FILTER_PRED * sizeof(pred),
> > + GFP_KERNEL);
> > + if (!system->preds)
> > + return -ENOMEM;
> > + }
> > +
> > + for (i = 0; i < MAX_FILTER_PRED; i++) {
> > + if (!system->preds[i]) {
> > + system->preds[i] = pred;
> > + break;
> > + }
> > + if (i == MAX_FILTER_PRED - 1)
> > + return -EINVAL;
>
>
> Shouldn't it be i == MAX_FILTER_PRED ?

Here we search for a free slot in the array of sub-expressions of
the subsystem level filters. That condition cannot even be true
inside a 'i < MAX_FILTER_PRED' loop.

Checking for i==MAX would be fine if done outside of the loop - and
should probably be done that way. But the code is correct this way
too i think.

Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/