Re: [PATCH] init/main.c: check for null pointer before calling initcall

From: Thomas Gleixner
Date: Fri Oct 27 2017 - 15:43:15 EST


On Fri, 27 Oct 2017, Abderrahmane Benbachir wrote:
> David Daney <ddaney@xxxxxxxxxxxxxxxxxx> a ÃcritÂ:
>
> > On 10/27/2017 11:22 AM, Thomas Gleixner wrote:
> > > On Fri, 27 Oct 2017, David Daney wrote:
> > >
> > > > On 10/27/2017 09:47 AM, Abderrahmane Benbachir wrote:
> > > > > Simple check to prevent kernel panic when initcall does not exit
> > > >
> > > > Interesting, under what circumstances do you observe the panic?
> > > >
> > > > It would be best to include this information in the patch changelog.
> > >
> > > device_initcall(NULL);
> > >
> > > might do that, but then it rightfully crashes on boot.
> > >
> >
> > That was kind of my point. The module loader case already checks for a
> > non-NULL pointer, and any NULLs in the in-kernel initializer tables would
> > indicate a bigger problem that should be fixed instead.
> >
> > David Daney
>
> But this code can still be written :
>
> static initcall_t __initcall_mymod \
> __used __section(".initcall6.init") = NULL;

You can write that, but it's simply wrong and abusing the initcall
system. As I said, the system rightfully crashes.

There are sane ways to do conditional initialization from within a fixed
initcall.

Thanks,

tglx