Skip to contentSkip to conversation

ath:Release resources for structure pointer, ar if error pointing device in the function, ath10k_core_register_work

PATCH In review Nicholas Krause 2 participants 3 messages Mar 3, 2015

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

PATCH 1/1 ath:Release resources for structure pointer, ar if error pointing device in the function, ath10k_core_register_work

Releases resources and deregisters the stucture pointer ar passed by the caller to the function, ath10k_core_register_work if unable to probe the structure pointer successfully with a call to ath10k_core_probe_fw. Further more if this happerns we must first jump to the label err for the goto statement required to jump to handle this particular error in the function, ath10k_core_register_work. After we are in the correct error section we must free the resources for the structure pointer,ar with a call to the function, ath10k_core_unregister to free resources allocated for the structure pointer,ar.

---
 drivers/net/wireless/ath/ath10k/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +1 -3
index 310e12b..8b2ca25 100644
@@ -1307,9 +1307,7 @@ err_unregister_mac:
 err_release_fw:
 	ath10k_core_free_firmware_files(ar);
 err:
-	/* TODO: It's probably a good idea to release device from the driver
-	 * but calling device_release_driver() here will cause a deadlock.
-	 */
+	ath10k_core_unregister(ar);
 	return;
 }
 
Signature · 1 line
2.1.0
#1 lore raw
Quoted 16 lines · Nicholas Krause

Releases resources and deregisters the stucture pointer ar passed by the caller to the function, ath10k_core_register_work if unable to probe the structure pointer successfully with a call to ath10k_core_probe_fw. Further more if this happerns we must first jump to the label err for the goto statement required to jump to handle this particular error in the function, ath10k_core_register_work. After we are in the correct error section we must free the resources for the structure pointer,ar with a call to the function, ath10k_core_unregister to free resources allocated for the structure pointer,ar.

---
 drivers/net/wireless/ath/ath10k/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +0 -0
index 310e12b..8b2ca25 100644

drivers/net/wireless/ath/ath10k/core.c err_unregister_mac: · line 1312

Quoted 9 lines
drivers/net/wireless/ath/ath10k/core.c +1 -3
@@ -1307,9 +1307,7 @@ err_unregister_mac:
 err_release_fw:
        ath10k_core_free_firmware_files(ar);
 err:
-       /* TODO: It's probably a good idea to release device from the driver
-        * but calling device_release_driver() here will cause a deadlock.
-        */
+       ath10k_core_unregister(ar);
        return;
 }

Did you test this? This will deadlock. ath10k_core_unregister() tries to cancel ar->register_work. This won't work if you call it from the worker itself. Moreover if I ignore the deadlock ath10k_core_unregister() would do nothing else in this context because ATH10K_FLAG_CORE_REGISTERED wouldn't be even set.

If you're interested in dealing with this TODO I suggest you read through the original thread which led to the current state of affairs:

http://www.spinics.net/lists/linux-wireless/msg124004.html

Michał

author
#2 lore raw
Quoted 33 lines · Michal Kazior
Quoted 16 lines · Nicholas Krause

Releases resources and deregisters the stucture pointer ar passed by the caller to the function, ath10k_core_register_work if unable to probe the structure pointer successfully with a call to ath10k_core_probe_fw. Further more if this happerns we must first jump to the label err for the goto statement required to jump to handle this particular error in the function, ath10k_core_register_work. After we are in the correct error section we must free the resources for the structure pointer,ar with a call to the function, ath10k_core_unregister to free resources allocated for the structure pointer,ar.

---
 drivers/net/wireless/ath/ath10k/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +0 -0
index 310e12b..8b2ca25 100644

drivers/net/wireless/ath/ath10k/core.c err_unregister_mac: · line 1312

Quoted 9 lines
drivers/net/wireless/ath/ath10k/core.c +1 -3
@@ -1307,9 +1307,7 @@ err_unregister_mac:
 err_release_fw:
        ath10k_core_free_firmware_files(ar);
 err:
-       /* TODO: It's probably a good idea to release device from the driver
-        * but calling device_release_driver() here will cause a deadlock.
-        */
+       ath10k_core_unregister(ar);
        return;
 }

Did you test this? This will deadlock. ath10k_core_unregister() tries to cancel ar->register_work. This won't work if you call it from the worker itself. Moreover if I ignore the deadlock ath10k_core_unregister() would do nothing else in this context because ATH10K_FLAG_CORE_REGISTERED wouldn't be even set.

Quoted 8 lines

If you're interested in dealing with this TODO I suggest you read through the original thread which led to the current state of affairs:

http://www.spinics.net/lists/linux-wireless/msg124004.html

Michał

Michal,
Thanks for the info and the thread related to this issue. After reading it I was wondering if we can test my patch on actual hardware using this driver with my patch included in order to see what issues are still there. I don't have the hardware lying around for this but if someone can test my patch out and see where there are still deadlock issues or other bugs to my patch I am certain I will be able to figure this out. Thanks,
Nick
P.S. I am a student so my budget for test hardware is a little thin. :(

_______________________________________________
ath10k mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/ath10k