[PATCH net-next 01/10] net: ipa: Don't error out in .remove()

From
Uwe Kleine-König <hidden>
Date
2023-11-17 09:59:54
Reply to
Uwe Kleine-König, 2023-11-17
Returning early from .remove() with an error code still results in the
driver unbinding the device. So the driver core ignores the returned error
code and the resources that were not freed are never catched up. In
combination with devm this also often results in use-after-free bugs.

Here even if the modem cannot be stopped, resources must be freed. So
replace the early error return by an error message an continue to clean up.

This prepares changing ipa_remove() to return void.

Fixes: cdf2e9419dd9 ("soc: qcom: ipa: main code")
Signed-off-by: Uwe Kleine-König <redacted>
---
 drivers/net/ipa/ipa_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c
index da853353a5c7..60e4f590f5de 100644
--- a/drivers/net/ipa/ipa_main.c
+++ b/drivers/net/ipa/ipa_main.c
@@ -960,7 +960,8 @@ static int ipa_remove(struct platform_device *pdev)
 			ret = ipa_modem_stop(ipa);
 		}
 		if (ret)
-			return ret;
+			dev_err(dev, "Failed to stop modem (%pe)\n",
+				ERR_PTR(ret));
 
 		ipa_teardown(ipa);
 	}
-- 
2.42.0
Thread (23 messages) 23 messages, 7 authors, last reply 2023-11-22
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help