nvmf: Check callocs for failures

There were two unchecked allocations in the nvmf library. Check
for allocation failures.

Change-Id: Ic6b3104d825dba1ee6bd1748fa99e132702f300c
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Ben Walker 2016-08-05 15:46:13 -07:00
parent 2cf599b378
commit 644b903b6c

View File

@ -171,6 +171,9 @@ spdk_nvmf_subsystem_add_listener(struct spdk_nvmf_subsystem *subsystem,
struct spdk_nvmf_listen_addr *listen_addr;
listen_addr = calloc(1, sizeof(*listen_addr));
if (!listen_addr) {
return -1;
}
listen_addr->traddr = strdup(traddr);
listen_addr->trsvc = strdup(trsvc);
listen_addr->transport = transport;
@ -187,6 +190,9 @@ spdk_nvmf_subsystem_add_host(struct spdk_nvmf_subsystem *subsystem, char *host_n
struct spdk_nvmf_host *host;
host = calloc(1, sizeof(*host));
if (!host) {
return -1;
}
host->nqn = strdup(host_nqn);
TAILQ_INSERT_HEAD(&subsystem->hosts, host, link);