Re: [PATCH] sched/uclamp: potential dereference of null pointer

From: Steven Rostedt
Date: Thu Dec 09 2021 - 10:25:23 EST


On Thu, 9 Dec 2021 10:23:13 -0500
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -8125,6 +8125,8 @@ void __init sched_init(void)
> > #endif
> > if (ptr) {
> > ptr = (unsigned long)kzalloc(ptr, GFP_NOWAIT);
> > + if (!ptr)
> > + return;
>
> If this were to happen the system would crash immediately, with or without
> the return.
>
> If you are worried about not being able to allocate ptr, then the only
> reasonable fix here is
>
> BUG_ON(!ptr);
>
> That way you would know exactly why your system crashed. Because just
> returning would crash for other reasons and make it less debuggable.

And this is not worth the churn (because if it failed to allocate, you have
bigger problems to deal with).

So NAK on this change.

-- Steve