[PATCH] netifd: fix wdev->data lifetime

John Crispin john at phrozen.org
Tue Jun 23 04:12:17 EDT 2020


The reconf patch breaks wifi down under certain conditions. The root cause
is that during reload the wdev state gets flushed. This has the effect, that
the phy is lost from the state resulting in teardown breaking.
Fix this by changing the lifetime of wdev->data.

Signed-off-by: John Crispin <john at phrozen.org>
---
 wireless.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/wireless.c b/wireless.c
index efb7992..0aad8c7 100644
--- a/wireless.c
+++ b/wireless.c
@@ -275,8 +275,6 @@ wireless_device_free_state(struct wireless_device *wdev)
 	uloop_timeout_cancel(&wdev->script_check);
 	uloop_timeout_cancel(&wdev->timeout);
 	wireless_complete_kill_request(wdev);
-	free(wdev->data);
-	wdev->data = NULL;
 	vlist_for_each_element(&wdev->interfaces, vif, node) {
 		free(vif->data);
 		vif->data = NULL;
@@ -460,6 +458,7 @@ wireless_device_free(struct wireless_device *wdev)
 	vlist_flush_all(&wdev->vlans);
 	vlist_flush_all(&wdev->stations);
 	avl_delete(&wireless_devices.avl, &wdev->node.avl);
+	free(wdev->data);
 	free(wdev->config);
 	free(wdev->prev_config);
 	free(wdev);
@@ -1415,6 +1414,8 @@ wireless_device_notify(struct wireless_device *wdev, struct blob_attr *data,
 			return UBUS_STATUS_INVALID_ARGUMENT;
 
 		*pdata = blob_memdup(cur);
+		if (*pdata)
+			free(*pdata);
 		if (vif)
 			wireless_interface_set_data(vif);
 		else if (vlan)
-- 
2.25.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
http://lists.infradead.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list