[PATCH v2 18/54] net/e1000/base: fix infinite loop

Anatoly Burakov anatoly.burakov at intel.com
Tue Feb 4 16:10:24 CET 2025


From: Dima Ruinskiy <dima.ruinskiy at intel.com>

When the driver fails to acquire HW semaphore, there is nothing that can be
done to address it, so just leave to avoid an infinite loop.

Signed-off-by: Dima Ruinskiy <dima.ruinskiy at intel.com>
Signed-off-by: Anatoly Burakov <anatoly.burakov at intel.com>
---
 drivers/net/intel/e1000/base/e1000_i225.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/net/intel/e1000/base/e1000_i225.c b/drivers/net/intel/e1000/base/e1000_i225.c
index d7dc982ac3..18a4b38cba 100644
--- a/drivers/net/intel/e1000/base/e1000_i225.c
+++ b/drivers/net/intel/e1000/base/e1000_i225.c
@@ -340,8 +340,15 @@ void e1000_release_swfw_sync_i225(struct e1000_hw *hw, u16 mask)
 
 	DEBUGFUNC("e1000_release_swfw_sync_i225");
 
-	while (e1000_get_hw_semaphore_i225(hw) != E1000_SUCCESS)
-		; /* 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 (e1000_get_hw_semaphore_i225(hw) != E1000_SUCCESS) {
+		DEBUGOUT("Failed to release SW_FW_SYNC.\n");
+		return;
+	}
 
 	swfw_sync = E1000_READ_REG(hw, E1000_SW_FW_SYNC);
 	swfw_sync &= ~mask;
-- 
2.43.5



More information about the dev mailing list