client-node: free port io memmap also if port gone

clear_port() clears all struct mix and removes the port, and can occur
before port io is set to NULL.  In this case the port memmaps are not
freed, and are leaked until client pool closes.

Fix by freeing the old io memmap when setting io to NULL, also when the
port was already cleared, so that the memmap lifecycle is the same as
that of the IO.
This commit is contained in:
Pauli Virtanen 2024-03-29 19:51:07 +02:00
parent cc0f7596d6
commit a9911f68a0

View file

@ -692,15 +692,19 @@ static int do_port_set_io(struct impl *impl,
direction == SPA_DIRECTION_INPUT ? "input" : "output",
port_id, mix_id, data, size);
port = GET_PORT(impl, direction, port_id);
if (port == NULL)
return data == NULL ? 0 : -EINVAL;
if ((mix = find_mix(port, mix_id)) == NULL)
return -EINVAL;
old = pw_mempool_find_tag(impl->client_pool, tag, sizeof(tag));
port = GET_PORT(impl, direction, port_id);
if (port == NULL) {
pw_memmap_free(old);
return data == NULL ? 0 : -EINVAL;
}
if ((mix = find_mix(port, mix_id)) == NULL) {
pw_memmap_free(old);
return -EINVAL;
}
if (data) {
mm = pw_mempool_import_map(impl->client_pool,
impl->context_pool, data, size, tag);