Various minor and not so minor fixes suggested by Coverity.

In at least one case, it's amazing that target mode worked at all.

Found by: Coverity.
MFC after:	2 weeks
This commit is contained in:
Matt Jacob 2010-06-02 23:31:27 +00:00
parent f0e78b02bd
commit a035b0afa0
4 changed files with 52 additions and 44 deletions

View File

@ -3936,14 +3936,18 @@ isp_login_device(ispsoftc_t *isp, int chan, uint32_t portid, isp_pdb_t *p, uint1
i = lim;
}
break;
} else if (r != MBOX_LOOP_ID_USED) {
} else if ((r & 0xffff) == MBOX_LOOP_ID_USED) {
/*
* Try the next loop id.
*/
*ohp = handle;
handle = isp_nxt_handle(isp, chan, handle);
} else {
/*
* Give up.
*/
i = lim;
break;
} else if (r == MBOX_TIMEOUT) {
return (-1);
} else {
*ohp = handle;
handle = isp_nxt_handle(isp, chan, *ohp);
}
}
@ -4313,8 +4317,7 @@ isp_start(XS_T *xs)
reqp->req_header.rqs_entry_type = RQSTYPE_REQUEST;
}
}
/* reqp->req_header.rqs_flags = 0; */
/* reqp->req_header.rqs_seqno = 0; */
if (IS_24XX(isp)) {
int ttype;
if (XS_TAG_P(xs)) {
@ -4363,37 +4366,45 @@ isp_start(XS_T *xs)
reqp->req_flags = XS_TAG_TYPE(xs);
}
}
cdbp = reqp->req_cdb;
tptr = &reqp->req_time;
if (IS_SCSI(isp)) {
reqp->req_target = target | (XS_CHANNEL(xs) << 7);
reqp->req_lun_trn = XS_LUN(xs);
reqp->req_cdblen = XS_CDBLEN(xs);
cdbp = reqp->req_cdb;
} else if (IS_24XX(isp)) {
ispreqt7_t *t7 = (ispreqt7_t *)local;
fcportdb_t *lp;
lp = &FCPARAM(isp, XS_CHANNEL(xs))->portdb[hdlidx];
((ispreqt7_t *)reqp)->req_nphdl = target;
((ispreqt7_t *)reqp)->req_tidlo = lp->portid;
((ispreqt7_t *)reqp)->req_tidhi = lp->portid >> 16;
((ispreqt7_t *)reqp)->req_vpidx = ISP_GET_VPIDX(isp, XS_CHANNEL(xs));
t7->req_nphdl = target;
t7->req_tidlo = lp->portid;
t7->req_tidhi = lp->portid >> 16;
t7->req_vpidx = ISP_GET_VPIDX(isp, XS_CHANNEL(xs));
if (XS_LUN(xs) > 256) {
((ispreqt7_t *)reqp)->req_lun[0] = XS_LUN(xs) >> 8;
((ispreqt7_t *)reqp)->req_lun[0] |= 0x40;
t7->req_lun[0] = XS_LUN(xs) >> 8;
t7->req_lun[0] |= 0x40;
}
((ispreqt7_t *)reqp)->req_lun[1] = XS_LUN(xs);
cdbp = ((ispreqt7_t *)reqp)->req_cdb;
tptr = &((ispreqt7_t *)reqp)->req_time;
t7->req_lun[1] = XS_LUN(xs);
cdbp = t7->req_cdb;
tptr = &t7->req_time;
} else if (ISP_CAP_2KLOGIN(isp)) {
((ispreqt2e_t *)reqp)->req_target = target;
((ispreqt2e_t *)reqp)->req_scclun = XS_LUN(xs);
ispreqt2e_t *t2e = (ispreqt2e_t *)local;
t2e->req_target = target;
t2e->req_scclun = XS_LUN(xs);
cdbp = t2e->req_cdb;
} else if (ISP_CAP_SCCFW(isp)) {
((ispreqt2_t *)reqp)->req_target = target;
((ispreqt2_t *)reqp)->req_scclun = XS_LUN(xs);
ispreqt2_t *t2 = (ispreqt2_t *)local;
t2->req_target = target;
t2->req_scclun = XS_LUN(xs);
cdbp = t2->req_cdb;
} else {
((ispreqt2_t *)reqp)->req_target = target;
((ispreqt2_t *)reqp)->req_lun_trn = XS_LUN(xs);
ispreqt2_t *t2 = (ispreqt2_t *)local;
t2->req_target = target;
t2->req_lun_trn = XS_LUN(xs);
cdbp = t2->req_cdb;
}
ISP_MEMCPY(cdbp, XS_CDBP(xs), XS_CDBLEN(xs));

View File

@ -284,7 +284,7 @@ isp_detach(ispsoftc_t *isp)
config_intrhook_disestablish(&isp->isp_osinfo.ehook);
isp->isp_osinfo.ehook_active = 0;
}
if (isp->isp_osinfo.devq == NULL) {
if (isp->isp_osinfo.devq != NULL) {
cam_simq_free(isp->isp_osinfo.devq);
isp->isp_osinfo.devq = NULL;
}
@ -1910,7 +1910,7 @@ isp_handle_platform_atio2(ispsoftc_t *isp, at2_entry_t *aep)
tstate_t *tptr;
struct ccb_accept_tio *atiop;
uint16_t nphdl;
atio_private_data_t *atp = NULL;
atio_private_data_t *atp;
inot_private_data_t *ntp;
/*
@ -2063,9 +2063,6 @@ isp_handle_platform_atio2(ispsoftc_t *isp, at2_entry_t *aep)
rls_lun_statep(isp, tptr);
return;
noresrc:
if (atp) {
isp_put_atpd(isp, tptr, atp);
}
ntp = isp_get_ntpd(isp, tptr);
if (ntp == NULL) {
rls_lun_statep(isp, tptr);
@ -2500,7 +2497,7 @@ isp_handle_platform_notify_fc(ispsoftc_t *isp, in_fcentry_t *inp)
lun = inp->in_lun;
}
if (ISP_CAP_2KLOGIN(isp)) {
loopid = ((in_fcentry_e_t *)inot)->in_iid;
loopid = ((in_fcentry_e_t *)inp)->in_iid;
} else {
loopid = inp->in_iid;
}

View File

@ -1338,7 +1338,7 @@ isp_put_vp_ctrl_info(ispsoftc_t *isp, vp_ctrl_info_t *src, vp_ctrl_info_t *dst)
ISP_IOXPUT_16(isp, src->vp_ctrl_idmap[i], &dst->vp_ctrl_idmap[i]);
}
for (i = 0; i < ASIZE(src->vp_ctrl_reserved); i++) {
ISP_IOXPUT_8(isp, src->vp_ctrl_idmap[i], &dst->vp_ctrl_idmap[i]);
ISP_IOXPUT_8(isp, src->vp_ctrl_reserved[i], &dst->vp_ctrl_reserved[i]);
}
}

View File

@ -641,7 +641,7 @@ isp_pci_attach(device_t dev)
int isp_nvports = 0;
uint32_t data, cmd, linesz, did;
struct isp_pcisoftc *pcs;
ispsoftc_t *isp = NULL;
ispsoftc_t *isp;
size_t psize, xsize;
char fwname[32];
@ -966,30 +966,28 @@ isp_pci_attach(device_t dev)
return (0);
bad:
if (pcs && pcs->ih) {
if (pcs->ih) {
(void) bus_teardown_intr(dev, irq, pcs->ih);
}
if (locksetup && isp) {
if (locksetup) {
mtx_destroy(&isp->isp_osinfo.lock);
}
if (irq) {
(void) bus_release_resource(dev, SYS_RES_IRQ, iqd, irq);
}
if (pcs && pcs->msicount) {
if (pcs->msicount) {
pci_release_msi(dev);
}
if (regs) {
(void) bus_release_resource(dev, rtp, rgd, regs);
}
if (pcs) {
if (pcs->pci_isp.isp_param) {
free(pcs->pci_isp.isp_param, M_DEVBUF);
pcs->pci_isp.isp_param = NULL;
}
if (pcs->pci_isp.isp_osinfo.pc.ptr) {
free(pcs->pci_isp.isp_osinfo.pc.ptr, M_DEVBUF);
pcs->pci_isp.isp_osinfo.pc.ptr = NULL;
}
if (pcs->pci_isp.isp_param) {
free(pcs->pci_isp.isp_param, M_DEVBUF);
pcs->pci_isp.isp_param = NULL;
}
if (pcs->pci_isp.isp_osinfo.pc.ptr) {
free(pcs->pci_isp.isp_osinfo.pc.ptr, M_DEVBUF);
pcs->pci_isp.isp_osinfo.pc.ptr = NULL;
}
return (ENXIO);
}
@ -1725,6 +1723,8 @@ tdma2(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error)
bus_dmamap_sync(isp->isp_osinfo.dmat, PISP_PCMD(csio)->dmap, BUS_DMASYNC_PREREAD);
ddir = ISP_FROM_DEVICE;
} else {
dm_segs = NULL;
nseg = 0;
ddir = ISP_NOXFR;
}
} else {