Diff between 11d4823fa011bd99ba13a4ec147b2ff223f4a86e and 0b1247f07fbc4b9c368612c0fbcc5bb5a8fdbf1a

Changed Files

File Additions Deletions Status
mesh/net.c +6 -2 modified

Full Patch

diff --git a/mesh/net.c b/mesh/net.c
index 01a475d..9e0ea86 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -2899,8 +2899,12 @@ struct mesh_io *mesh_net_detach(struct mesh_net *net)
 	io = net->io;
 
 	mesh_io_send_cancel(net->io, &type, 1);
-	mesh_io_deregister_recv_cb(io, snb, sizeof(snb));
-	mesh_io_deregister_recv_cb(io, pkt, sizeof(pkt));
+
+	/* Only deregister io if this is the last network detached.*/
+	if (l_queue_length(nets) < 2) {
+		mesh_io_deregister_recv_cb(io, snb, sizeof(snb));
+		mesh_io_deregister_recv_cb(io, pkt, sizeof(pkt));
+	}
 
 	net->io = NULL;
 	l_queue_remove(nets, net);