[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <alpine.DEB.1.10.0901061227280.10871@gandalf.stny.rr.com>
Date: Tue, 6 Jan 2009 12:28:32 -0500 (EST)
From: Steven Rostedt <rostedt@...dmis.org>
To: Frederic Weisbecker <fweisbec@...il.com>
cc: Ingo Molnar <mingo@...e.hu>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Pekka Enberg <penberg@...helsinki.fi>,
Eduard - Gabriel Munteanu <eduard.munteanu@...ux360.ro>
Subject: Re: [PATCH 1/2] tracing/ftrace: handle more than one stat file per
tracer
On Tue, 6 Jan 2009, Frederic Weisbecker wrote:
> > > +
> > > + if (all_stat_sessions) {
> > > + for (i = 0; i < nb_sessions; i++) {
> > > + session = all_stat_sessions[i];
> > > + reset_stat_session(session);
> > > + mutex_destroy(&session->stat_mutex);
> > > + kfree(session);
> > > + }
> > > + }
> > > + all_stat_sessions = kmalloc(sizeof(struct tracer_stat_session *) * nb,
> > > + GFP_KERNEL);
> >
> > You want this to be kzalloc.
> >
> > > + if (!all_stat_sessions)
> > > + return -ENOMEM;
> > > +
> > > + for (i = 0; i < nb; i++) {
> > > + session = kmalloc(sizeof(struct tracer_stat_session) * nb,
> > > + GFP_KERNEL);
> >
> > Not so important, but you probably want to do it here too.
> >
> > > + if (!session)
> > > + goto free_sessions;
> > > +
> > > + INIT_LIST_HEAD(&session->stat_list.list);
> > > + mutex_init(&session->stat_mutex);
> > > + session->ts = &ts[i];
> > > + all_stat_sessions[i] = session;
> > > + }
> > > + nb_sessions = nb;
> > > + return 0;
> > > +
> > > +free_sessions:
> > > +
> > > + for (j = 0; j < i; j++)
> > > + kfree(all_stat_sessions[i]);
> >
> > With out the kzalloc above, this may crash the kernel, because
> > all_stat_sessions[i] might not be NULL when they were not initialized.
>
>
> I'm not sure. j will not go through indexes of rooms that weren't allocated.
Ah, OK, my eyes confused i's and j's so I did not notice the loop to last
failed. Which is strange because I write similar code :-/.
-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists