From eb09c17a542b2feead2e318febf8c62d074abcad Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Tue, 6 May 2025 15:06:12 +0200 Subject: [PATCH] os: ospoll_create(): protect from allocation failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit | ../os/ospoll.c: In function ‘ospoll_create’: | ../os/ospoll.c:229:22: warning: dereference of possibly-NULL ‘ospoll’ [CWE-690] [-Wanalyzer-possible-null-dereference] | 229 | ospoll->epoll_fd = epoll_create1(EPOLL_CLOEXEC); | | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Enrico Weigelt, metux IT consult --- os/ospoll.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/os/ospoll.c b/os/ospoll.c index dc2ecd10f..59355b367 100644 --- a/os/ospoll.c +++ b/os/ospoll.c @@ -224,8 +224,9 @@ ospoll_create(void) return ospoll; #endif #if EPOLL - struct ospoll *ospoll = calloc(1, sizeof (struct ospoll)); - + struct ospoll *ospoll = calloc(1, sizeof (struct ospoll)); + if (ospoll == NULL) + return NULL; ospoll->epoll_fd = epoll_create1(EPOLL_CLOEXEC); if (ospoll->epoll_fd < 0) { free (ospoll);