Date: Sun, 27 Jul 2014 06:49:55 +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: r269149 - head/sys/cam/ctl Message-ID: <201407270649.s6R6ntKa021628@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Sun Jul 27 06:49:55 2014 New Revision: 269149 URL: http://svnweb.freebsd.org/changeset/base/269149 Log: Fix several cases of NULL dereference when INQUIRY sent to absent LUN. MFC after: 3 days Modified: head/sys/cam/ctl/ctl.c Modified: head/sys/cam/ctl/ctl.c ============================================================================== --- head/sys/cam/ctl/ctl.c Sun Jul 27 05:44:42 2014 (r269148) +++ head/sys/cam/ctl/ctl.c Sun Jul 27 06:49:55 2014 (r269149) @@ -10024,7 +10024,8 @@ ctl_inquiry_evpd_scsi_ports(struct ctl_s STAILQ_FOREACH(port, &softc->port_list, links) { if ((port->status & CTL_PORT_STATUS_ONLINE) == 0) continue; - if (ctl_map_lun_back(port->targ_port, lun->lun) >= + if (lun != NULL && + ctl_map_lun_back(port->targ_port, lun->lun) >= CTL_MAX_LUNS) continue; num_target_ports++; @@ -10080,7 +10081,8 @@ ctl_inquiry_evpd_scsi_ports(struct ctl_s STAILQ_FOREACH(port, &softc->port_list, links) { if ((port->status & CTL_PORT_STATUS_ONLINE) == 0) continue; - if (ctl_map_lun_back(port->targ_port, lun->lun) >= + if (lun != NULL && + ctl_map_lun_back(port->targ_port, lun->lun) >= CTL_MAX_LUNS) continue; p = port->targ_port % CTL_MAX_PORTS + g * CTL_MAX_PORTS; @@ -10123,7 +10125,6 @@ ctl_inquiry_evpd_block_limits(struct ctl int bs; lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; - bs = lun->be_lun->blocksize; ctsio->kern_data_ptr = malloc(sizeof(*bl_ptr), M_CTL, M_WAITOK | M_ZERO); bl_ptr = (struct scsi_vpd_block_limits *)ctsio->kern_data_ptr; @@ -10157,10 +10158,13 @@ ctl_inquiry_evpd_block_limits(struct ctl scsi_ulto2b(sizeof(*bl_ptr), bl_ptr->page_length); bl_ptr->max_cmp_write_len = 0xff; scsi_ulto4b(0xffffffff, bl_ptr->max_txfer_len); - scsi_ulto4b(MAXPHYS / bs, bl_ptr->opt_txfer_len); - if (lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) { - scsi_ulto4b(0xffffffff, bl_ptr->max_unmap_lba_cnt); - scsi_ulto4b(0xffffffff, bl_ptr->max_unmap_blk_cnt); + if (lun != NULL) { + bs = lun->be_lun->blocksize; + scsi_ulto4b(MAXPHYS / bs, bl_ptr->opt_txfer_len); + if (lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) { + scsi_ulto4b(0xffffffff, bl_ptr->max_unmap_lba_cnt); + scsi_ulto4b(0xffffffff, bl_ptr->max_unmap_blk_cnt); + } } scsi_u64to8b(UINT64_MAX, bl_ptr->max_write_same_length); @@ -10177,10 +10181,8 @@ ctl_inquiry_evpd_lbp(struct ctl_scsiio * { struct scsi_vpd_logical_block_prov *lbp_ptr; struct ctl_lun *lun; - int bs; lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; - bs = lun->be_lun->blocksize; ctsio->kern_data_ptr = malloc(sizeof(*lbp_ptr), M_CTL, M_WAITOK | M_ZERO); lbp_ptr = (struct scsi_vpd_logical_block_prov *)ctsio->kern_data_ptr; @@ -10211,7 +10213,7 @@ ctl_inquiry_evpd_lbp(struct ctl_scsiio * lbp_ptr->device = (SID_QUAL_LU_OFFLINE << 5) | T_DIRECT; lbp_ptr->page_code = SVPD_LBP; - if (lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) + if (lun != NULL && lun->be_lun->flags & CTL_LUN_FLAG_UNMAP) lbp_ptr->flags = SVPD_LBP_UNMAP | SVPD_LBP_WS16 | SVPD_LBP_WS10; ctsio->scsi_status = SCSI_STATUS_OK;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201407270649.s6R6ntKa021628>