Fix several cases of NULL dereference when INQUIRY sent to absent LUN.
MFC after: 3 days
This commit is contained in:
parent
c821a62f9c
commit
1b5307b2b0
@ -10024,7 +10024,8 @@ ctl_inquiry_evpd_scsi_ports(struct ctl_scsiio *ctsio, int alloc_len)
|
||||
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_scsiio *ctsio, int alloc_len)
|
||||
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_scsiio *ctsio, int alloc_len)
|
||||
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_scsiio *ctsio, int alloc_len)
|
||||
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 *ctsio, int alloc_len)
|
||||
{
|
||||
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 *ctsio, int alloc_len)
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user