svn commit: r279276 - head/usr.sbin/ctld
Alexander Motin
mav at FreeBSD.org
Wed Feb 25 10:07:41 UTC 2015
Author: mav
Date: Wed Feb 25 10:07:39 2015
New Revision: 279276
URL: https://svnweb.freebsd.org/changeset/base/279276
Log:
Add checks for malloc() failures.
Submitted by: Dmitry Luhtionov <dmitryluhtionov at gmail.com>
MFC after: 3 days
Modified:
head/usr.sbin/ctld/kernel.c
Modified: head/usr.sbin/ctld/kernel.c
==============================================================================
--- head/usr.sbin/ctld/kernel.c Wed Feb 25 09:57:05 2015 (r279275)
+++ head/usr.sbin/ctld/kernel.c Wed Feb 25 10:07:39 2015 (r279276)
@@ -901,7 +901,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");
@@ -1015,6 +1018,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);
More information about the svn-src-all
mailing list