On Mon, 17 Nov 2025 22:06:15 -0500 Steven Rostedt <[email protected]> wrote:
> On Tue, 18 Nov 2025 11:09:46 +0900 > Masami Hiramatsu (Google) <[email protected]> wrote: > > > On Mon, 17 Nov 2025 15:41:08 -0300 > > Wander Lairson Costa <[email protected]> wrote: > > > > > The actions_init() and actions_new() functions did not check the > > > return value of calloc() and realloc() respectively. In a low > > > memory situation, this could lead to a NULL pointer dereference. > > > > > > Add checks for the return value of memory allocation functions > > > and return an error in case of failure. Update the callers to > > > handle the error properly. > > > > > > Signed-off-by: Wander Lairson Costa <[email protected]> > > > --- > > > tools/tracing/rtla/src/actions.c | 26 +++++++++++++++++++++++--- > > > tools/tracing/rtla/src/actions.h | 2 +- > > > tools/tracing/rtla/src/timerlat_hist.c | 7 +++++-- > > > tools/tracing/rtla/src/timerlat_top.c | 7 +++++-- > > > 4 files changed, 34 insertions(+), 8 deletions(-) > > > > > > diff --git a/tools/tracing/rtla/src/actions.c > > > b/tools/tracing/rtla/src/actions.c > > > index 8945aee58d511..01648a1425c10 100644 > > > --- a/tools/tracing/rtla/src/actions.c > > > +++ b/tools/tracing/rtla/src/actions.c > > > @@ -11,11 +11,13 @@ > > > /* > > > * actions_init - initialize struct actions > > > */ > > > -void > > > +int > > > actions_init(struct actions *self) > > > { > > > self->size = action_default_size; > > > self->list = calloc(self->size, sizeof(struct action)); > > > + if (!self->list) > > > + return -1; > > > > Can you return -ENOMEM? > > Does it need to? This is user space not the kernel. Errno is already > set by calloc() failing. Ah, indeed! I agree to just return -1. Reviewed-by: Masami Hiramatsu (Google) <[email protected]> Thank you, > > -- Steve > -- Masami Hiramatsu (Google) <[email protected]>
