scsi: dpt_i2o: use after free in __adpt_reset()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 19 Mar 2018 10:34:01 +0000 (13:34 +0300)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 21 Mar 2018 22:34:19 +0000 (18:34 -0400)
In __adpt_reset() the problem is that adpt_hba_reset() frees "pHba" on
error but we dereference it to print the name in the error message.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/dpt_i2o.c

index 67379e4d0bf97622d5e6f8af2502d03db41a682e..35d45903ed2e9c0459f816ab3c470ba01a940be2 100644 (file)
@@ -799,14 +799,17 @@ static int __adpt_reset(struct scsi_cmnd* cmd)
 {
        adpt_hba* pHba;
        int rcode;
+       char name[32];
+
        pHba = (adpt_hba*)cmd->device->host->hostdata[0];
-       printk(KERN_WARNING"%s: Hba Reset: scsi id %d: tid: %d\n",pHba->name,cmd->device->channel,pHba->channel[cmd->device->channel].tid );
+       strncpy(name, pHba->name, sizeof(name));
+       printk(KERN_WARNING"%s: Hba Reset: scsi id %d: tid: %d\n", name, cmd->device->channel, pHba->channel[cmd->device->channel].tid);
        rcode =  adpt_hba_reset(pHba);
        if(rcode == 0){
-               printk(KERN_WARNING"%s: HBA reset complete\n",pHba->name);
+               printk(KERN_WARNING"%s: HBA reset complete\n", name);
                return SUCCESS;
        } else {
-               printk(KERN_WARNING"%s: HBA reset failed (%x)\n",pHba->name, rcode);
+               printk(KERN_WARNING"%s: HBA reset failed (%x)\n", name, rcode);
                return FAILED;
        }
 }