From 05c3dfeedf3120945f81a935119a2cfe084f4785 Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Sat, 14 Nov 2015 16:18:22 +0000 Subject: [PATCH] Add missing error checks. MFC after: 1 month Sponsored by: The FreeBSD Foundation --- usr.sbin/ctld/kernel.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/usr.sbin/ctld/kernel.c b/usr.sbin/ctld/kernel.c index 4b4e3fa82676..8f1cefb99c11 100644 --- a/usr.sbin/ctld/kernel.c +++ b/usr.sbin/ctld/kernel.c @@ -516,13 +516,19 @@ conf_new_from_kernel(void) if (strcmp(port->port_frontend, "ha") == 0) continue; free(name); - if (port->pp == 0 && port->vp == 0) + if (port->pp == 0 && port->vp == 0) { name = checked_strdup(port->port_name); - else if (port->vp == 0) - asprintf(&name, "%s/%d", port->port_name, port->pp); - else - asprintf(&name, "%s/%d/%d", port->port_name, port->pp, - port->vp); + } else if (port->vp == 0) { + retval = asprintf(&name, "%s/%d", + port->port_name, port->pp); + if (retval <= 0) + log_err(1, "asprintf"); + } else { + retval = asprintf(&name, "%s/%d/%d", + port->port_name, port->pp, port->vp); + if (retval <= 0) + log_err(1, "asprintf"); + } if (port->cfiscsi_target == NULL) { log_debugx("CTL port %u \"%s\" wasn't managed by ctld; ",