Commit e84d96db authored by Dan Carpenter's avatar Dan Carpenter Committed by James Bottomley

[SCSI] dpt_i2o: move range check forward

The check to test that "bus_no" was valid came after we had already used
it as an array offset.  This patch moves it forward.
Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
parent 32de5960
...@@ -2640,6 +2640,13 @@ static s32 adpt_i2o_reparse_lct(adpt_hba* pHba) ...@@ -2640,6 +2640,13 @@ static s32 adpt_i2o_reparse_lct(adpt_hba* pHba)
continue; continue;
} }
bus_no = buf[0]>>16; bus_no = buf[0]>>16;
if (bus_no >= MAX_CHANNEL) { /* Something wrong skip it */
printk(KERN_WARNING
"%s: Channel number %d out of range\n",
pHba->name, bus_no);
continue;
}
scsi_id = buf[1]; scsi_id = buf[1];
scsi_lun = (buf[2]>>8 )&0xff; scsi_lun = (buf[2]>>8 )&0xff;
pDev = pHba->channel[bus_no].device[scsi_id]; pDev = pHba->channel[bus_no].device[scsi_id];
...@@ -2668,10 +2675,6 @@ static s32 adpt_i2o_reparse_lct(adpt_hba* pHba) ...@@ -2668,10 +2675,6 @@ static s32 adpt_i2o_reparse_lct(adpt_hba* pHba)
adpt_i2o_report_hba_unit(pHba, d); adpt_i2o_report_hba_unit(pHba, d);
adpt_i2o_install_device(pHba, d); adpt_i2o_install_device(pHba, d);
if(bus_no >= MAX_CHANNEL) { // Something wrong skip it
printk(KERN_WARNING"%s: Channel number %d out of range \n", pHba->name, bus_no);
continue;
}
pDev = pHba->channel[bus_no].device[scsi_id]; pDev = pHba->channel[bus_no].device[scsi_id];
if( pDev == NULL){ if( pDev == NULL){
pDev = pDev =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment