From e3500d9977d5643527f9a56e92b16df6b78c0222 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 21 Mar 2018 18:58:22 -0600 Subject: [PATCH] server: handle shared mem pool allocation failures Signed-off-by: Jens Axboe --- server.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server.c b/server.c index 6064d817..72d7b0a1 100644 --- a/server.c +++ b/server.c @@ -528,6 +528,9 @@ static struct sk_entry *fio_net_prep_cmd(uint16_t opcode, void *buf, struct sk_entry *entry; entry = smalloc(sizeof(*entry)); + if (!entry) + return NULL; + INIT_FLIST_HEAD(&entry->next); entry->opcode = opcode; if (flags & SK_F_COPY) { @@ -1359,6 +1362,11 @@ static int accept_loop(int listen_sk) dprint(FD_NET, "server: connect from %s\n", from); sk_out = smalloc(sizeof(*sk_out)); + if (!sk_out) { + close(sk); + return -1; + } + sk_out->sk = sk; INIT_FLIST_HEAD(&sk_out->list); __fio_sem_init(&sk_out->lock, FIO_SEM_UNLOCKED); -- 2.25.1