]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
[SCSI] dpt_i2o: move range check forward
authorDan Carpenter <error27@gmail.com>
Thu, 15 Jul 2010 08:20:19 +0000 (10:20 +0200)
committerJames Bottomley <James.Bottomley@suse.de>
Wed, 28 Jul 2010 14:05:43 +0000 (09:05 -0500)
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: Dan Carpenter <error27@gmail.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
drivers/scsi/dpt_i2o.c

index f2d4df14c311520da5c8f9b73beea275c4444f50..ffc1edf5e80da4bb9158caa312a395029539a29c 100644 (file)
@@ -2640,6 +2640,13 @@ static s32 adpt_i2o_reparse_lct(adpt_hba* pHba)
                                continue;
                        }
                        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_lun = (buf[2]>>8 )&0xff;
                        pDev = pHba->channel[bus_no].device[scsi_id];
@@ -2668,10 +2675,6 @@ static s32 adpt_i2o_reparse_lct(adpt_hba* pHba)
                                adpt_i2o_report_hba_unit(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];   
                                if( pDev == NULL){
                                        pDev =