Skip to contentSkip to conversation

igc: Fix infinite loop in release_swfw_sync

PATCH New Sasha Neftin 2 participants 2 messages Mar 1, 2022 – Mar 15, 2022

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

PATCH 1/1 igc: Fix infinite loop in release_swfw_sync

An infinite loop may occur if we fail to acquire the HW semaphore, which is needed for resource release.
This will typically happen if the hardware is surprise-removed. At this stage there is nothing to do, except log an error and quit.

---
 drivers/net/ethernet/intel/igc/igc_i225.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igc/igc_i225.c +9 -2
index 66ea566488d1..59d5c467ea6e 100644
@@ -156,8 +156,15 @@ void igc_release_swfw_sync_i225(struct igc_hw *hw, u16 mask)
 {
 	u32 swfw_sync;
 
-	while (igc_get_hw_semaphore_i225(hw))
-		; /* Empty */
+	/* Releasing the resource requires first getting the HW semaphore.
+	 * If we fail to get the semaphore, there is nothing we can do,
+	 * except log an error and quit. We are not allowed to hang here
+	 * indefinitely, as it may cause denial of service or system crash.
+	 */
+	if (igc_get_hw_semaphore_i225(hw)) {
+		hw_dbg("Failed to release SW_FW_SYNC.\n");
+		return;
+	}
 
 	swfw_sync = rd32(IGC_SW_FW_SYNC);
 	swfw_sync &= ~mask;
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/1 igc: Fix infinite loop in release_swfw_sync

Quoted 10 lines · Sasha Neftin

An infinite loop may occur if we fail to acquire the HW semaphore, which is needed for resource release.
This will typically happen if the hardware is surprise-removed. At this stage there is nothing to do, except log an error and quit.

---
  drivers/net/ethernet/intel/igc/igc_i225.c | 11 +++++++++--
  1 file changed, 9 insertions(+), 2 deletions(-)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20220315/e4f90db1/attachment.html>