[PATCH RESEND] tracing: Fix overflow in get_free_elt()
Steven Rostedt
rostedt at goodmis.org
Wed Aug 7 06:29:36 PDT 2024
On Wed, 7 Aug 2024 11:34:43 +0000
Tze-nan Wu (吳澤南) <Tze-nan.Wu at mediatek.com> wrote:
> > > -idx = atomic_inc_return(&map->next_elt);
> > > +idx = atomic_fetch_add_unless(&map->next_elt, 1, map->max_elts);
> >
> > I guess we need to add (with a comment):
> >
> > idx--;
> >
> Thanks for reviewing this!
>
> By reference to "/include/linux/atomic/atomic-instrumented.h",
> `atomic_fetch_add_unless` will return the original value before the
> adding happens on operands.
Ah, right. I haven't used that before and was thinking this was the same as
the inc_return().
-- Steve
More information about the Linux-mediatek
mailing list