Skip to contentSkip to conversation

thunderbolt: Initialize ->domain_released completion before it is being used

PATCH Applied Mika Westerberg 2 participants 4 messages Jul 28 – Jul 30

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thunderbolt: Initialize ->domain_released completion before it is being used

Both Woody and Marek reported following crash:

 BUG: unable to handle page fault for address: fffffffffffffff8
 Call Trace:
  <TASK>
  device_release+0x43/0x90
  kobject_cleanup+0x3c/0x180
  icm_probe+0x19c/0x550 [thunderbolt]
  nhi_probe+0x1a4/0x370 [thunderbolt]
  local_pci_probe+0x41/0x90
  pci_call_probe+0x5b/0x1a0
  ...

This only triggers on the error path when icm_probe() fails and the domain structure is released, it tries to complete() uninitialized completion.

Fix this by initializing the completion earlier.

---
 drivers/thunderbolt/nhi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/thunderbolt/nhi.c +2 -2
index 0f795ea58756..35e3c119d5ee 100644
@@ -1226,6 +1226,8 @@ int nhi_probe(struct tb_nhi *nhi)
 			return dev_err_probe(dev, res, "NHI specific init failed\n");
 	}
 
+	init_completion(&nhi->domain_released);
+
 	tb = nhi_select_cm(nhi);
 	if (!tb)
 		return dev_err_probe(dev, -ENODEV,
@@ -1233,8 +1235,6 @@ int nhi_probe(struct tb_nhi *nhi)
 
 	dev_dbg(dev, "NHI initialized, starting thunderbolt\n");
 
-	init_completion(&nhi->domain_released);
-
 	res = tb_domain_add(tb, host_reset);
 	if (res) {
 		/*
Signature · 1 line
2.50.1
author Applied
#1 lore raw
Quoted 17 lines · Mika Westerberg

Both Woody and Marek reported following crash:

 BUG: unable to handle page fault for address: fffffffffffffff8
 Call Trace:
  <TASK>
  device_release+0x43/0x90
  kobject_cleanup+0x3c/0x180
  icm_probe+0x19c/0x550 [thunderbolt]
  nhi_probe+0x1a4/0x370 [thunderbolt]
  local_pci_probe+0x41/0x90
  pci_call_probe+0x5b/0x1a0
  ...

This only triggers on the error path when icm_probe() fails and the domain structure is released, it tries to complete() uninitialized completion.

Quoted 8 lines

Fix this by initializing the completion earlier.

Applied to thunderbolt.git/fixes.

#2 lore raw
Quoted 20 lines · Mika Westerberg
Quoted 19 lines · Mika Westerberg

Both Woody and Marek reported following crash:

  BUG: unable to handle page fault for address: fffffffffffffff8
  Call Trace:
   <TASK>
   device_release+0x43/0x90
   kobject_cleanup+0x3c/0x180
   icm_probe+0x19c/0x550 [thunderbolt]
   nhi_probe+0x1a4/0x370 [thunderbolt]
   local_pci_probe+0x41/0x90
   pci_call_probe+0x5b/0x1a0
   ...

This only triggers on the error path when icm_probe() fails and the domain structure is released, it tries to complete() uninitialized completion.

Fix this by initializing the completion earlier.

Quoted 7 lines
Quoted 6 lines

Applied to thunderbolt.git/fixes.

The patch seems to work OK. I can see |/sys/bus/thunderbolt/devices/domain0/.

Tested_by: Woody Suwalski <[email protected]>

|

#3 lore raw
Quoted 27 lines · Woody Suwalski
Quoted 26 lines · Mika Westerberg
Quoted 25 lines · Mika Westerberg

Both Woody and Marek reported following crash:

  BUG: unable to handle page fault for address: fffffffffffffff8
  Call Trace:
   <TASK>
   device_release+0x43/0x90
   kobject_cleanup+0x3c/0x180
   icm_probe+0x19c/0x550 [thunderbolt]
   nhi_probe+0x1a4/0x370 [thunderbolt]
   local_pci_probe+0x41/0x90
   pci_call_probe+0x5b/0x1a0
   ...

This only triggers on the error path when icm_probe() fails and the domain structure is released, it tries to complete() uninitialized completion.

Fix this by initializing the completion earlier.

Quoted 5 lines
Quoted 1 line

Applied to thunderbolt.git/fixes.

The patch seems to work OK. I can see
|/sys/bus/thunderbolt/devices/domain0/.

Tested_by: Woody Suwalski <[email protected]>

Thanks for testing! I added your tag to the commit now.