From: Ammar Faizi <ammarfaizi2@xxxxxxxxxxx> Replace `malloc()` + `memset()` with `calloc()`. While in there, handle the ENOMEM case of it. Signed-off-by: Ammar Faizi <ammarfaizi2@xxxxxxxxxxx> --- engines/net.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/engines/net.c b/engines/net.c index c6cec584..8a898748 100644 --- a/engines/net.c +++ b/engines/net.c @@ -1363,6 +1363,10 @@ static int fio_netio_setup(struct thread_data *td) { struct netio_data *nd; + nd = calloc(1, sizeof(*nd)); + if (!nd) + return 1; + if (!td->files_index) { add_file(td, td->o.filename ?: "net", 0, 0); td->o.nr_files = td->o.nr_files ?: 1; @@ -1370,9 +1374,6 @@ static int fio_netio_setup(struct thread_data *td) } if (!td->io_ops_data) { - nd = malloc(sizeof(*nd)); - - memset(nd, 0, sizeof(*nd)); nd->listenfd = -1; nd->pipes[0] = nd->pipes[1] = -1; td->io_ops_data = nd; @@ -1391,7 +1392,8 @@ static int fio_netio_setup_splice(struct thread_data *td) { struct netio_data *nd; - fio_netio_setup(td); + if (fio_netio_setup(td)) + return 1; nd = td->io_ops_data; if (nd) { -- Ammar Faizi