From 08e65ce8aee394c065f373cbc45cf0d996f0138e Mon Sep 17 00:00:00 2001 From: Mikhail Dmitrichenko Date: Mon, 18 May 2026 14:32:55 +0300 Subject: [PATCH] os: check ospoll allocation failures ospoll_create() initializes backend-specific state immediately after allocating the ospoll structure. Check the allocation result for each backend before dereferencing it and return NULL on failure. Signed-off-by: Mikhail Dmitrichenko Part-of: --- os/ospoll.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/os/ospoll.c b/os/ospoll.c index bca039a10..31dfd0527 100644 --- a/os/ospoll.c +++ b/os/ospoll.c @@ -207,6 +207,8 @@ ospoll_create(void) { #if POLLSET struct ospoll *ospoll = calloc(1, sizeof (struct ospoll)); + if (!ospoll) + return NULL; ospoll->ps = pollset_create(-1); if (ospoll->ps < 0) { @@ -217,6 +219,8 @@ ospoll_create(void) #endif #if PORT struct ospoll *ospoll = calloc(1, sizeof (struct ospoll)); + if (!ospoll) + return NULL; ospoll->epoll_fd = port_create(); if (ospoll->epoll_fd < 0) { @@ -228,6 +232,8 @@ ospoll_create(void) #endif #if EPOLL struct ospoll *ospoll = calloc(1, sizeof (struct ospoll)); + if (!ospoll) + return NULL; ospoll->epoll_fd = epoll_create1(EPOLL_CLOEXEC); if (ospoll->epoll_fd < 0) {