summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ctld
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-03-01 09:29:59 +0000
committermav <mav@FreeBSD.org>2015-03-01 09:29:59 +0000
commit8882db8870fcd94fca831da0651e180ccdc148e3 (patch)
treebffb64c5678bd5be39f464d29d0d864898cbb80b /usr.sbin/ctld
parent47c76cda5688854a09ee981b073e966f2516b175 (diff)
downloadFreeBSD-src-8882db8870fcd94fca831da0651e180ccdc148e3.zip
FreeBSD-src-8882db8870fcd94fca831da0651e180ccdc148e3.tar.gz
MFC r279276: Add checks for malloc() failures.
Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com>
Diffstat (limited to 'usr.sbin/ctld')
-rw-r--r--usr.sbin/ctld/kernel.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/usr.sbin/ctld/kernel.c b/usr.sbin/ctld/kernel.c
index a94fa2b..59afbee 100644
--- a/usr.sbin/ctld/kernel.c
+++ b/usr.sbin/ctld/kernel.c
@@ -864,7 +864,10 @@ kernel_port_add(struct port *port)
bzero(&req, sizeof(req));
strlcpy(req.driver, "iscsi", sizeof(req.driver));
req.reqtype = CTL_REQ_CREATE;
+ req.num_args = 5;
req.args = malloc(req.num_args * sizeof(*req.args));
+ if (req.args == NULL)
+ log_err(1, "malloc");
n = 0;
req.args[n].namelen = sizeof("port_id");
req.args[n].name = __DECONST(char *, "port_id");
@@ -978,6 +981,8 @@ kernel_port_remove(struct port *port)
req.reqtype = CTL_REQ_REMOVE;
req.num_args = 2;
req.args = malloc(req.num_args * sizeof(*req.args));
+ if (req.args == NULL)
+ log_err(1, "malloc");
str_arg(&req.args[0], "cfiscsi_target", targ->t_name);
snprintf(tagstr, sizeof(tagstr), "%d", pg->pg_tag);
str_arg(&req.args[1], "cfiscsi_portal_group_tag", tagstr);
OpenPOWER on IntegriCloud