From owner-svn-src-head@FreeBSD.ORG Thu Sep 27 10:51:38 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E96B0106564A; Thu, 27 Sep 2012 10:51:38 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D323F8FC14; Thu, 27 Sep 2012 10:51:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q8RApcxg002955; Thu, 27 Sep 2012 10:51:38 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q8RApcmq002950; Thu, 27 Sep 2012 10:51:38 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201209271051.q8RApcmq002950@svn.freebsd.org> From: Edward Tomasz Napierala Date: Thu, 27 Sep 2012 10:51:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r240993 - head/sys/cam/ctl X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Sep 2012 10:51:39 -0000 Author: trasz Date: Thu Sep 27 10:51:38 2012 New Revision: 240993 URL: http://svn.freebsd.org/changeset/base/240993 Log: Remove useless NULL checks after M_WAITOK allocations. Modified: head/sys/cam/ctl/ctl.c head/sys/cam/ctl/ctl_backend_block.c head/sys/cam/ctl/ctl_backend_ramdisk.c head/sys/cam/ctl/scsi_ctl.c Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Thu Sep 27 10:46:22 2012 (r240992) +++ head/sys/cam/ctl/ctl.c Thu Sep 27 10:51:38 2012 (r240993) @@ -1520,12 +1520,6 @@ ctl_ioctl_do_datamove(struct ctl_scsiio ext_sglist = (struct ctl_sg_entry *)malloc(ext_sglen, M_CTL, M_WAITOK); - if (ext_sglist == NULL) { - ctl_set_internal_failure(ctsio, - /*sks_valid*/ 0, - /*retry_count*/ 0); - return (CTL_RETVAL_COMPLETE); - } ext_sglist_malloced = 1; if (copyin(ctsio->ext_data_ptr, ext_sglist, ext_sglen) != 0) { @@ -2028,11 +2022,6 @@ ctl_copyin_alloc(void *user_addr, int le void *kptr; kptr = malloc(len, M_CTL, M_WAITOK | M_ZERO); - if (kptr == NULL) { - snprintf(error_str, error_str_len, "Cannot allocate %d bytes", - len); - return (NULL); - } if (copyin(user_addr, kptr, len) != 0) { snprintf(error_str, error_str_len, "Error copying %d bytes " @@ -2764,12 +2753,6 @@ ctl_ioctl(struct cdev *dev, u_long cmd, new_err_desc = malloc(sizeof(*new_err_desc), M_CTL, M_WAITOK | M_ZERO); - if (new_err_desc == NULL) { - printf("%s: CTL_ERROR_INJECT: error allocating %zu " - "bytes\n", __func__, sizeof(*new_err_desc)); - retval = ENOMEM; - break; - } bcopy(err_desc, new_err_desc, sizeof(*new_err_desc)); mtx_lock(&softc->ctl_lock); @@ -4203,11 +4186,6 @@ ctl_alloc_lun(struct ctl_softc *ctl_soft } if (ctl_lun == NULL) { lun = malloc(sizeof(*lun), M_CTL, M_WAITOK); - if (lun == NULL) { - be_lun->lun_config_status(lun->be_lun->be_lun, - CTL_LUN_CONFIG_FAILURE); - return (-ENOMEM); - } lun->flags = CTL_LUN_MALLOCED; } else lun = ctl_lun; @@ -5061,12 +5039,6 @@ ctl_scsi_release(struct ctl_scsiio *ctsi if (((ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) == 0) && (length > 0)) { ctsio->kern_data_ptr = malloc(length, M_CTL, M_WAITOK); - if (ctsio->kern_data_ptr == NULL) { - ctsio->io_hdr.status = CTL_SCSI_ERROR; - ctsio->io_hdr.status = SCSI_STATUS_BUSY; - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); - } ctsio->kern_data_len = length; ctsio->kern_total_len = length; ctsio->kern_data_resid = 0; @@ -5202,12 +5174,6 @@ ctl_scsi_reserve(struct ctl_scsiio *ctsi if (((ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) == 0) && (length > 0)) { ctsio->kern_data_ptr = malloc(length, M_CTL, M_WAITOK); - if (ctsio->kern_data_ptr == NULL) { - ctsio->io_hdr.status = CTL_SCSI_ERROR; - ctsio->io_hdr.status = SCSI_STATUS_BUSY; - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); - } ctsio->kern_data_len = length; ctsio->kern_total_len = length; ctsio->kern_data_resid = 0; @@ -5573,12 +5539,6 @@ ctl_format(struct ctl_scsiio *ctsio) if (((ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) == 0) && (length > 0)) { ctsio->kern_data_ptr = malloc(length, M_CTL, M_WAITOK); - if (ctsio->kern_data_ptr == NULL) { - ctsio->io_hdr.status = CTL_SCSI_ERROR; - ctsio->io_hdr.status = SCSI_STATUS_BUSY; - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); - } ctsio->kern_data_len = length; ctsio->kern_total_len = length; ctsio->kern_data_resid = 0; @@ -6368,11 +6328,6 @@ ctl_mode_select(struct ctl_scsiio *ctsio */ if ((ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) == 0) { ctsio->kern_data_ptr = malloc(param_len, M_CTL, M_WAITOK); - if (ctsio->kern_data_ptr == NULL) { - ctl_set_busy(ctsio); - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); - } ctsio->kern_data_len = param_len; ctsio->kern_total_len = param_len; ctsio->kern_data_resid = 0; @@ -6607,12 +6562,6 @@ ctl_mode_sense(struct ctl_scsiio *ctsio) #endif ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK); - if (ctsio->kern_data_ptr == NULL) { - ctsio->io_hdr.status = CTL_SCSI_ERROR; - ctsio->scsi_status = SCSI_STATUS_BUSY; - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); - } ctsio->kern_sg_entries = 0; ctsio->kern_data_resid = 0; ctsio->kern_rel_offset = 0; @@ -6794,12 +6743,6 @@ ctl_read_capacity(struct ctl_scsiio *cts lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; ctsio->kern_data_ptr = malloc(sizeof(*data), M_CTL, M_WAITOK); - if (ctsio->kern_data_ptr == NULL) { - ctsio->io_hdr.status = CTL_SCSI_ERROR; - ctsio->scsi_status = SCSI_STATUS_BUSY; - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); - } data = (struct scsi_read_capacity_data *)ctsio->kern_data_ptr; ctsio->residual = 0; ctsio->kern_data_len = sizeof(*data); @@ -6864,12 +6807,6 @@ ctl_read_capacity_16(struct ctl_scsiio * lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; ctsio->kern_data_ptr = malloc(sizeof(*data), M_CTL, M_WAITOK); - if (ctsio->kern_data_ptr == NULL) { - ctsio->io_hdr.status = CTL_SCSI_ERROR; - ctsio->scsi_status = SCSI_STATUS_BUSY; - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); - } data = (struct scsi_read_capacity_data_long *)ctsio->kern_data_ptr; if (sizeof(*data) < alloc_len) { @@ -6977,12 +6914,6 @@ ctl_maintenance_in(struct ctl_scsiio *ct alloc_len = scsi_4btoul(cdb->length); ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK); - if (ctsio->kern_data_ptr == NULL) { - ctsio->io_hdr.status = CTL_SCSI_ERROR; - ctsio->scsi_status = SCSI_STATUS_BUSY; - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); - } memset(ctsio->kern_data_ptr, 0, total_len); ctsio->kern_sg_entries = 0; @@ -7138,12 +7069,6 @@ retry: mtx_unlock(&softc->ctl_lock); ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK); - if (ctsio->kern_data_ptr == NULL) { - ctsio->io_hdr.status = CTL_SCSI_ERROR; - ctsio->scsi_status = SCSI_STATUS_BUSY; - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); - } if (total_len < alloc_len) { ctsio->residual = alloc_len - total_len; @@ -7876,11 +7801,6 @@ ctl_persistent_reserve_out(struct ctl_sc if ((ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) == 0) { ctsio->kern_data_ptr = malloc(param_len, M_CTL, M_WAITOK); - if (ctsio->kern_data_ptr == NULL) { - ctl_set_busy(ctsio); - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); - } ctsio->kern_data_len = param_len; ctsio->kern_total_len = param_len; ctsio->kern_data_resid = 0; @@ -8692,13 +8612,6 @@ ctl_report_luns(struct ctl_scsiio *ctsio (num_luns * sizeof(struct scsi_report_luns_lundata)); ctsio->kern_data_ptr = malloc(lun_datalen, M_CTL, M_WAITOK); - if (ctsio->kern_data_ptr == NULL) { - ctsio->io_hdr.status = CTL_SCSI_ERROR; - ctsio->scsi_status = SCSI_STATUS_BUSY; - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); - } - lun_data = (struct scsi_report_luns_data *)ctsio->kern_data_ptr; ctsio->kern_sg_entries = 0; @@ -8821,12 +8734,6 @@ ctl_request_sense(struct ctl_scsiio *cts sense_format = SSD_TYPE_FIXED; ctsio->kern_data_ptr = malloc(sizeof(*sense_ptr), M_CTL, M_WAITOK); - if (ctsio->kern_data_ptr == NULL) { - ctsio->io_hdr.status = CTL_SCSI_ERROR; - ctsio->scsi_status = SCSI_STATUS_BUSY; - ctl_done((union ctl_io *)ctsio); - return (CTL_RETVAL_COMPLETE); - } sense_ptr = (struct scsi_sense_data *)ctsio->kern_data_ptr; ctsio->kern_sg_entries = 0; Modified: head/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- head/sys/cam/ctl/ctl_backend_block.c Thu Sep 27 10:46:22 2012 (r240992) +++ head/sys/cam/ctl/ctl_backend_block.c Thu Sep 27 10:51:38 2012 (r240993) @@ -376,9 +376,6 @@ ctl_grow_beio(struct ctl_be_block_softc beio = (struct ctl_be_block_io *)malloc(sizeof(*beio), M_CTLBLK, M_WAITOK | M_ZERO); - if (beio == NULL) - break; - bzero(beio, sizeof(*beio)); beio->softc = softc; mtx_lock(&softc->lock); @@ -1092,15 +1089,6 @@ ctl_be_block_dispatch(struct ctl_be_bloc */ beio->sg_segs[i].len = min(MAXPHYS, len_left); beio->sg_segs[i].addr = uma_zalloc(be_lun->lun_zone, M_WAITOK); - /* - * uma_zalloc() can in theory return NULL even with M_WAITOK - * if it can't pull more memory into the zone. - */ - if (beio->sg_segs[i].addr == NULL) { - ctl_set_busy(&io->scsiio); - ctl_complete_beio(beio); - return; - } DPRINTF("segment %d addr %p len %zd\n", i, beio->sg_segs[i].addr, beio->sg_segs[i].len); @@ -1660,13 +1648,6 @@ ctl_be_block_create(struct ctl_be_block_ be_lun = malloc(sizeof(*be_lun), M_CTLBLK, M_ZERO | M_WAITOK); - if (be_lun == NULL) { - snprintf(req->error_str, sizeof(req->error_str), - "%s: error allocating %zd bytes", __func__, - sizeof(*be_lun)); - goto bailout_error; - } - be_lun->softc = softc; STAILQ_INIT(&be_lun->input_queue); STAILQ_INIT(&be_lun->config_write_queue); @@ -1705,12 +1686,6 @@ ctl_be_block_create(struct ctl_be_block_ be_lun->dev_path = malloc(file_arg->vallen, M_CTLBLK, M_WAITOK | M_ZERO); - if (be_lun->dev_path == NULL) { - snprintf(req->error_str, sizeof(req->error_str), - "%s: error allocating %d bytes", __func__, - file_arg->vallen); - goto bailout_error; - } strlcpy(be_lun->dev_path, (char *)file_arg->value, file_arg->vallen); Modified: head/sys/cam/ctl/ctl_backend_ramdisk.c ============================================================================== --- head/sys/cam/ctl/ctl_backend_ramdisk.c Thu Sep 27 10:46:22 2012 (r240992) +++ head/sys/cam/ctl/ctl_backend_ramdisk.c Thu Sep 27 10:51:38 2012 (r240993) @@ -134,7 +134,7 @@ ctl_backend_ramdisk_init(void) { struct ctl_be_ramdisk_softc *softc; #ifdef CTL_RAMDISK_PAGES - int i, j; + int i; #endif @@ -151,17 +151,8 @@ ctl_backend_ramdisk_init(void) softc->ramdisk_pages = (uint8_t **)malloc(sizeof(uint8_t *) * softc->num_pages, M_RAMDISK, M_WAITOK); - for (i = 0; i < softc->num_pages; i++) { + for (i = 0; i < softc->num_pages; i++) softc->ramdisk_pages[i] = malloc(PAGE_SIZE, M_RAMDISK,M_WAITOK); - if (softc->ramdisk_pages[i] == NULL) { - for (j = 0; j < i; j++) { - free(softc->ramdisk_pages[j], M_RAMDISK); - } - free(softc->ramdisk_pages, M_RAMDISK); - panic("RAMDisk initialization failed\n"); - return (1); /* NOTREACHED */ - } - } #else softc->ramdisk_buffer = (uint8_t *)malloc(softc->rd_size, M_RAMDISK, M_WAITOK); @@ -313,13 +304,6 @@ ctl_backend_ramdisk_submit(union ctl_io io->scsiio.kern_data_ptr = malloc(sizeof(struct ctl_sg_entry) * num_sg_entries, M_RAMDISK, M_WAITOK); - if (io->scsiio.kern_data_ptr == NULL) { - ctl_set_internal_failure(&io->scsiio, - /*sks_valid*/ 0, - /*retry_count*/ 0); - ctl_done(io); - return (CTL_RETVAL_COMPLETE); - } sg_entries = (struct ctl_sg_entry *)io->scsiio.kern_data_ptr; for (i = 0, len_filled = 0; i < num_sg_entries; i++, len_filled += PAGE_SIZE) { Modified: head/sys/cam/ctl/scsi_ctl.c ============================================================================== --- head/sys/cam/ctl/scsi_ctl.c Thu Sep 27 10:46:22 2012 (r240992) +++ head/sys/cam/ctl/scsi_ctl.c Thu Sep 27 10:51:38 2012 (r240993) @@ -1694,11 +1694,6 @@ ctlfe_onoffline(void *arg, int online) return; } ccb = (union ccb *)malloc(sizeof(*ccb), M_TEMP, M_WAITOK | M_ZERO); - if (ccb == NULL) { - printf("%s: unable to malloc CCB!\n", __func__); - xpt_free_path(path); - return; - } xpt_setup_ccb(&ccb->ccb_h, path, /*priority*/ 1); sim = xpt_path_sim(path); @@ -1900,12 +1895,6 @@ ctlfe_lun_enable(void *arg, struct ctl_i } softc = malloc(sizeof(*softc), M_CTLFE, M_WAITOK | M_ZERO); - if (softc == NULL) { - printf("%s: could not allocate %zd bytes for softc\n", - __func__, sizeof(*softc)); - xpt_free_path(path); - return (1); - } sim = xpt_path_sim(path); mtx_lock(sim->mtx); periph = cam_periph_find(path, "ctl");