From 96594d6716d91e86bf8e2f715abe7e19d103d62c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 5 May 2026 11:36:45 +0200 Subject: [PATCH] plugins: handle some fd allocation errors --- spa/plugins/audiotestsrc/audiotestsrc.c | 2 ++ spa/plugins/bluez5/media-source.c | 2 ++ spa/plugins/bluez5/midi-node.c | 4 ++++ spa/plugins/support/node-driver.c | 2 ++ spa/plugins/support/null-audio-sink.c | 2 ++ spa/plugins/test/fakesink.c | 2 ++ spa/plugins/test/fakesrc.c | 2 ++ spa/plugins/vulkan/vulkan-compute-source.c | 2 ++ src/modules/module-client-node/client-node.c | 2 ++ 9 files changed, 20 insertions(+) diff --git a/spa/plugins/audiotestsrc/audiotestsrc.c b/spa/plugins/audiotestsrc/audiotestsrc.c index 3414e8b18..447f214fd 100644 --- a/spa/plugins/audiotestsrc/audiotestsrc.c +++ b/spa/plugins/audiotestsrc/audiotestsrc.c @@ -1067,6 +1067,8 @@ impl_init(const struct spa_handle_factory *factory, this->timer_source.data = this; this->timer_source.fd = spa_system_timerfd_create(this->data_system, CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK); + if (this->timer_source.fd < 0) + return this->timer_source.fd; this->timer_source.mask = SPA_IO_IN; this->timer_source.rmask = 0; diff --git a/spa/plugins/bluez5/media-source.c b/spa/plugins/bluez5/media-source.c index e1c01d90c..0aa79a544 100644 --- a/spa/plugins/bluez5/media-source.c +++ b/spa/plugins/bluez5/media-source.c @@ -2270,6 +2270,8 @@ impl_init(const struct spa_handle_factory *factory, this->timerfd = spa_system_timerfd_create(this->data_system, CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK); + if (this->timerfd < 0) + return this->timerfd; this->node_latency = 512; diff --git a/spa/plugins/bluez5/midi-node.c b/spa/plugins/bluez5/midi-node.c index 671035b34..3e3ef78e6 100644 --- a/spa/plugins/bluez5/midi-node.c +++ b/spa/plugins/bluez5/midi-node.c @@ -2089,6 +2089,10 @@ impl_init(const struct spa_handle_factory *factory, this->timerfd = spa_system_timerfd_create(this->data_system, CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK); + if (this->timerfd < 0) { + res = this->timerfd; + goto fail; + } return 0; diff --git a/spa/plugins/support/node-driver.c b/spa/plugins/support/node-driver.c index 175dc53c8..693e2da5f 100644 --- a/spa/plugins/support/node-driver.c +++ b/spa/plugins/support/node-driver.c @@ -1042,6 +1042,8 @@ impl_init(const struct spa_handle_factory *factory, this->timer_source.data = this; this->timer_source.fd = spa_system_timerfd_create(this->data_system, this->timer_clockid, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK); + if (this->timer_source.fd < 0) + return this->timer_source.fd; this->timer_source.mask = SPA_IO_IN; this->timer_source.rmask = 0; diff --git a/spa/plugins/support/null-audio-sink.c b/spa/plugins/support/null-audio-sink.c index 610adf9ce..770e86891 100644 --- a/spa/plugins/support/null-audio-sink.c +++ b/spa/plugins/support/null-audio-sink.c @@ -930,6 +930,8 @@ impl_init(const struct spa_handle_factory *factory, this->timer_source.data = this; this->timer_source.fd = spa_system_timerfd_create(this->data_system, CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK); + if (this->timer_source.fd < 0) + return this->timer_source.fd; this->timer_source.mask = SPA_IO_IN; this->timer_source.rmask = 0; diff --git a/spa/plugins/test/fakesink.c b/spa/plugins/test/fakesink.c index 31667a1de..c2ba3b7c6 100644 --- a/spa/plugins/test/fakesink.c +++ b/spa/plugins/test/fakesink.c @@ -708,6 +708,8 @@ impl_init(const struct spa_handle_factory *factory, this->timer_source.data = this; this->timer_source.fd = spa_system_timerfd_create(this->data_system, CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK); + if (this->timer_source.fd < 0) + return this->timer_source.fd; this->timer_source.mask = SPA_IO_IN; this->timer_source.rmask = 0; diff --git a/spa/plugins/test/fakesrc.c b/spa/plugins/test/fakesrc.c index db28d9c3c..c6401b9b4 100644 --- a/spa/plugins/test/fakesrc.c +++ b/spa/plugins/test/fakesrc.c @@ -767,6 +767,8 @@ impl_init(const struct spa_handle_factory *factory, this->timer_source.data = this; this->timer_source.fd = spa_system_timerfd_create(this->data_system, CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK); + if (this->timer_source.fd < 0) + return this->timer_source.fd; this->timer_source.mask = SPA_IO_IN; this->timer_source.rmask = 0; diff --git a/spa/plugins/vulkan/vulkan-compute-source.c b/spa/plugins/vulkan/vulkan-compute-source.c index aa6f4a60f..08eacca02 100644 --- a/spa/plugins/vulkan/vulkan-compute-source.c +++ b/spa/plugins/vulkan/vulkan-compute-source.c @@ -906,6 +906,8 @@ impl_init(const struct spa_handle_factory *factory, this->timer_source.data = this; this->timer_source.fd = spa_system_timerfd_create(this->data_system, CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK); + if (this->timer_source.fd < 0) + return this->timer_source.fd; this->timer_source.mask = SPA_IO_IN; this->timer_source.rmask = 0; diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index 1e104429c..5b4b4351b 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -1392,6 +1392,8 @@ static void node_initialized(void *data) impl->data_source.fd = spa_system_eventfd_create(data_system, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK); + if (impl->data_source.fd < 0) + return; spa_loop_add_source(impl->data_loop, &impl->data_source); pw_log_debug("%p: transport read-fd:%d write-fd:%d", impl,