linux/drivers/thunderbolt
Mika Westerberg acb40d8412 thunderbolt: Initialize Thunderbolt bus earlier
The 0day kbuild robot reports following crash:

  BUG: unable to handle kernel NULL pointer dereference at 00000004
  IP: tb_property_find+0xe/0x41
  *pde = 00000000
  Oops: 0000 [#1]
  CPU: 0 PID: 1 Comm: swapper Not tainted 4.14.0-rc1-00741-ge69b6c0 #412
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014
  task: 89c80000 task.stack: 89c7c000
  EIP: tb_property_find+0xe/0x41
  EFLAGS: 00210246 CPU: 0
  EAX: 00000000 EBX: 7a368f47 ECX: 00000044 EDX: 7a368f47
  ESI: 8851d340 EDI: 7a368f47 EBP: 89c7df0c ESP: 89c7defc
   DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068
  CR0: 80050033 CR2: 00000004 CR3: 027a2000 CR4: 00000690
  Call Trace:
   tb_register_property_dir+0x49/0xb9
   ? cdc_mbim_driver_init+0x1b/0x1b
   tbnet_init+0x77/0x9f
   ? cdc_mbim_driver_init+0x1b/0x1b
   do_one_initcall+0x7e/0x145
   ? parse_args+0x10c/0x1b3
   ? kernel_init_freeable+0xbe/0x159
   kernel_init_freeable+0xd1/0x159
   ? rest_init+0x110/0x110
   kernel_init+0xd/0xd0
   ret_from_fork+0x19/0x30

The reason is that both Thunderbolt bus and thunderbolt-net are build
into the kernel image, and the latter is linked first because
drivers/net comes before drivers/thunderbolt. Since both use
module_init() thunderbolt-net ends up calling Thunderbolt bus functions
too early triggering the above crash.

Fix this by moving Thunderbolt bus initialization to happen earlier to
make sure all the data structures are ready when Thunderbolt service
drivers are initialized. To be on the safe side also add a check for
properly initialized xdomain_property_dir to tb_register_property_dir().

Reported-by: kernel test robot <fengguang.wu@intel.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-10-09 10:30:41 -07:00
..
cap.c thunderbolt: Rework capability handling 2017-06-09 11:42:41 +02:00
ctl.c thunderbolt: Add polling mode for rings 2017-10-02 11:24:41 -07:00
ctl.h thunderbolt: Add support for XDomain discovery protocol 2017-10-02 11:24:41 -07:00
dma_port.c thunderbolt: Add support for DMA configuration based mailbox 2017-06-09 11:42:43 +02:00
dma_port.h thunderbolt: Add support for DMA configuration based mailbox 2017-06-09 11:42:43 +02:00
domain.c thunderbolt: Add support for XDomain discovery protocol 2017-10-02 11:24:41 -07:00
eeprom.c thunderbolt: Do not enumerate more ports from DROM than the controller has 2017-08-10 14:25:35 -07:00
icm.c thunderbolt: Add support for XDomain discovery protocol 2017-10-02 11:24:41 -07:00
Kconfig thunderbolt: Add support for host and device NVM firmware upgrade 2017-06-09 11:42:43 +02:00
Makefile thunderbolt: Add support for XDomain discovery protocol 2017-10-02 11:24:41 -07:00
nhi_regs.h thunderbolt: Move ring descriptor flags to thunderbolt.h 2017-10-02 11:24:41 -07:00
nhi.c thunderbolt: Initialize Thunderbolt bus earlier 2017-10-09 10:30:41 -07:00
nhi.h thunderbolt: Export ring handling functions to modules 2017-10-02 11:24:41 -07:00
path.c thunderbolt: Clear hops before overwriting 2014-08-26 14:54:48 -07:00
property.c thunderbolt: Add support for XDomain properties 2017-10-02 11:24:40 -07:00
switch.c thunderbolt: Add support for XDomain discovery protocol 2017-10-02 11:24:41 -07:00
tb_msgs.h thunderbolt: Add support for XDomain discovery protocol 2017-10-02 11:24:41 -07:00
tb_regs.h thunderbolt: Rework capability handling 2017-06-09 11:42:41 +02:00
tb.c treewide: Consolidate Apple DMI checks 2017-08-03 23:26:22 +02:00
tb.h thunderbolt: Add support for XDomain discovery protocol 2017-10-02 11:24:41 -07:00
tunnel_pci.c thunderbolt: Introduce thunderbolt bus and connection manager 2017-06-09 11:42:41 +02:00
tunnel_pci.h thunderbolt: Add support for simple pci tunnels 2014-06-19 14:07:47 -07:00
xdomain.c thunderbolt: Initialize Thunderbolt bus earlier 2017-10-09 10:30:41 -07:00