struct gb_connection *connection;
connection = container_of(kref, struct gb_connection, kref);
- destroy_workqueue(connection->wq);
+
kfree(connection);
mutex_unlock(&connection_mutex);
}
}
EXPORT_SYMBOL_GPL(gb_connection_disable);
-/*
- * Tear down a previously set up connection.
- */
+/* Caller must have disabled the connection before destroying it. */
void gb_connection_destroy(struct gb_connection *connection)
{
struct ida *id_map;
list_del(&connection->hd_links);
spin_unlock_irq(&gb_connections_lock);
+ destroy_workqueue(connection->wq);
+
id_map = &connection->hd->cport_id_map;
ida_simple_remove(id_map, connection->hd_cport_id);
connection->hd_cport_id = CPORT_ID_BAD;