Thread (15 messages) 15 messages, 2 authors, 19d ago

Re: [PATCH net-next 3/3] r8169: release firmware on application failure

flat view

From: Andrew Lunn <andrew@lunn.ch>
Date: 2026-09-16 18:42:44
Also in: lkml

On Wed, Sep 16, 2026 at 12:24:44PM -0300, Matheus Alves de Almeida wrote:
quoted hunk ↗ jump to hunk
After an rtl_fw_write_firmware() failure, r8169_apply_firmware() does
not release the firmware. A TODO notes that it should be released
in this case.

Release the firmware on failure and remove the TODO.

Signed-off-by: Matheus Alves de Almeida <redacted>
---
 drivers/net/ethernet/realtek/r8169_main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
index 3c37c5a6c..c54423cd2 100644
--- a/drivers/net/ethernet/realtek/r8169_main.c
+++ b/drivers/net/ethernet/realtek/r8169_main.c
@@ -2596,12 +2596,14 @@ void r8169_apply_firmware(struct rtl8169_private *tp)
 {
 	int val;
 
-	/* TODO: release firmware if rtl_fw_write_firmware signals failure. */
 	if (tp->rtl_fw) {
-		rtl_fw_write_firmware(tp, tp->rtl_fw);
+		int rc = rtl_fw_write_firmware(tp, tp->rtl_fw);
 		/* At least one firmware doesn't reset tp->ocp_base. */
 		tp->ocp_base = OCP_STD_PHY_BASE;
 
+		if (rc < 0)
+			rtl_release_firmware(tp);
+
 		/* PHY soft reset may still be in progress */
 		if (tp->phydev)
 			phy_read_poll_timeout(tp->phydev, MII_BMCR, val,
If the firmware cannot be written, is the device dead? Should this
return an error, so the caller can abort the probe?

       Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help