Date: Wed, 25 Feb 2015 10:07:40 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r279276 - head/usr.sbin/ctld Message-ID: <201502251007.t1PA7eAj010198@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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@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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502251007.t1PA7eAj010198>