From owner-svn-src-all@FreeBSD.ORG Tue Jan 25 20:44:11 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DBC6D106566B; Tue, 25 Jan 2011 20:44:11 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CA4768FC14; Tue, 25 Jan 2011 20:44:11 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p0PKiBt2049735; Tue, 25 Jan 2011 20:44:11 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0PKiBEi049728; Tue, 25 Jan 2011 20:44:11 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201101252044.p0PKiBEi049728@svn.freebsd.org> From: John Baldwin Date: Tue, 25 Jan 2011 20:44:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217840 - stable/8/usr.sbin/mfiutil X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jan 2011 20:44:12 -0000 Author: jhb Date: Tue Jan 25 20:44:11 2011 New Revision: 217840 URL: http://svn.freebsd.org/changeset/base/217840 Log: MFC 204329,210723,210933,214778,215526: Sync mfiutil(8) with HEAD: - Handle malloc() failures more gracefully by error'ing out rather than segfaulting. - Fixed dependencies (make checkdpadd). - Fix typos and spelling mistakes. Modified: stable/8/usr.sbin/mfiutil/Makefile stable/8/usr.sbin/mfiutil/mfi_cmd.c stable/8/usr.sbin/mfiutil/mfi_config.c stable/8/usr.sbin/mfiutil/mfi_evt.c stable/8/usr.sbin/mfiutil/mfi_flash.c stable/8/usr.sbin/mfiutil/mfiutil.8 Directory Properties: stable/8/usr.sbin/mfiutil/ (props changed) Modified: stable/8/usr.sbin/mfiutil/Makefile ============================================================================== --- stable/8/usr.sbin/mfiutil/Makefile Tue Jan 25 20:33:47 2011 (r217839) +++ stable/8/usr.sbin/mfiutil/Makefile Tue Jan 25 20:44:11 2011 (r217840) @@ -8,6 +8,7 @@ MAN8= mfiutil.8 CFLAGS+= -fno-builtin-strftime WARNS?=3 +DPADD= ${LIBUTIL} LDADD= -lutil # Here be dragons Modified: stable/8/usr.sbin/mfiutil/mfi_cmd.c ============================================================================== --- stable/8/usr.sbin/mfiutil/mfi_cmd.c Tue Jan 25 20:33:47 2011 (r217839) +++ stable/8/usr.sbin/mfiutil/mfi_cmd.c Tue Jan 25 20:44:11 2011 (r217840) @@ -46,7 +46,7 @@ #include static const char *mfi_status_codes[] = { - "Command completed succesfully", + "Command completed successfully", "Invalid command", "Invalid DMCD opcode", "Invalid parameter", Modified: stable/8/usr.sbin/mfiutil/mfi_config.c ============================================================================== --- stable/8/usr.sbin/mfiutil/mfi_config.c Tue Jan 25 20:33:47 2011 (r217839) +++ stable/8/usr.sbin/mfiutil/mfi_config.c Tue Jan 25 20:44:11 2011 (r217840) @@ -328,6 +328,10 @@ parse_array(int fd, int raid_type, char /* Validate each drive. */ info->drives = calloc(count, sizeof(struct mfi_pd_info)); + if (info->drives == NULL) { + warnx("malloc failed"); + return (ENOMEM); + } info->drive_count = count; for (pinfo = info->drives; (cp = strsep(&array_str, ",")) != NULL; pinfo++) { @@ -638,6 +642,10 @@ create_volume(int ac, char **av) break; } arrays = calloc(narrays, sizeof(*arrays)); + if (arrays == NULL) { + warnx("malloc failed"); + return (ENOMEM); + } for (i = 0; i < narrays; i++) { error = parse_array(fd, raid_type, av[i], &arrays[i]); if (error) @@ -673,6 +681,10 @@ create_volume(int ac, char **av) state.array_count = config->array_count; if (config->array_count > 0) { state.arrays = calloc(config->array_count, sizeof(int)); + if (state.arrays == NULL) { + warnx("malloc failed"); + return (ENOMEM); + } for (i = 0; i < config->array_count; i++) { ar = (struct mfi_array *)p; state.arrays[i] = ar->array_ref; @@ -685,6 +697,10 @@ create_volume(int ac, char **av) state.log_drv_count = config->log_drv_count; if (config->log_drv_count) { state.volumes = calloc(config->log_drv_count, sizeof(int)); + if (state.volumes == NULL) { + warnx("malloc failed"); + return (ENOMEM); + } for (i = 0; i < config->log_drv_count; i++) { ld = (struct mfi_ld_config *)p; state.volumes[i] = ld->properties.ld.v.target_id; @@ -721,6 +737,10 @@ create_volume(int ac, char **av) config_size = sizeof(struct mfi_config_data) + sizeof(struct mfi_ld_config) * nvolumes + MFI_ARRAY_SIZE * narrays; config = calloc(1, config_size); + if (config == NULL) { + warnx("malloc failed"); + return (ENOMEM); + } config->size = config_size; config->array_count = narrays; config->array_size = MFI_ARRAY_SIZE; /* XXX: Firmware hardcode */ @@ -902,6 +922,10 @@ add_spare(int ac, char **av) spare = malloc(sizeof(struct mfi_spare) + sizeof(uint16_t) * config->array_count); + if (spare == NULL) { + warnx("malloc failed"); + return (ENOMEM); + } bzero(spare, sizeof(struct mfi_spare)); spare->ref = info.ref; @@ -1170,6 +1194,10 @@ dump(int ac, char **av) } config = malloc(len); + if (config == NULL) { + warnx("malloc failed"); + return (ENOMEM); + } if (sysctlbyname(buf, config, &len, NULL, 0) < 0) { error = errno; warn("Failed to read debug command"); Modified: stable/8/usr.sbin/mfiutil/mfi_evt.c ============================================================================== --- stable/8/usr.sbin/mfiutil/mfi_evt.c Tue Jan 25 20:33:47 2011 (r217839) +++ stable/8/usr.sbin/mfiutil/mfi_evt.c Tue Jan 25 20:44:11 2011 (r217840) @@ -624,6 +624,10 @@ show_events(int ac, char **av) } list = malloc(size); + if (list == NULL) { + warnx("malloc failed"); + return (ENOMEM); + } for (seq = start;;) { if (mfi_get_events(fd, list, num_events, filter, seq, &status) < 0) { Modified: stable/8/usr.sbin/mfiutil/mfi_flash.c ============================================================================== --- stable/8/usr.sbin/mfiutil/mfi_flash.c Tue Jan 25 20:33:47 2011 (r217839) +++ stable/8/usr.sbin/mfiutil/mfi_flash.c Tue Jan 25 20:44:11 2011 (r217840) @@ -163,6 +163,10 @@ flash_adapter(int ac, char **av) /* Upload the file 64k at a time. */ buf = malloc(FLASH_BUF_SIZE); + if (buf == NULL) { + warnx("malloc failed"); + return (ENOMEM); + } offset = 0; while (sb.st_size > 0) { nread = read(flash, buf, FLASH_BUF_SIZE); Modified: stable/8/usr.sbin/mfiutil/mfiutil.8 ============================================================================== --- stable/8/usr.sbin/mfiutil/mfiutil.8 Tue Jan 25 20:33:47 2011 (r217839) +++ stable/8/usr.sbin/mfiutil/mfiutil.8 Tue Jan 25 20:44:11 2011 (r217840) @@ -254,7 +254,7 @@ The default locale is The available locales are .Dq volume , .Dq drive , -.Dq enclousure , +.Dq enclosure , .Dq battery , .Dq sas , .Dq controller , @@ -503,7 +503,7 @@ Enable periodic patrol reads initiated b The optional .Ar interval argument specifies the interval in seconds between patrol reads. -If patrol reads should be run continously, +If patrol reads should be run continuously, then .Ar interval should consist of the word