Skip to content

Commit

Permalink
scsi: dpt_i2o: Use after free in I2ORESETCMD ioctl
Browse files Browse the repository at this point in the history
Here is another use after free if we reset the card.  The adpt_hba_reset()
function frees "pHba" on error.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Dan Carpenter authored and Martin K. Petersen committed Apr 10, 2018
1 parent f4abab3 commit 7709e9b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/scsi/dpt_i2o.c
Original file line number Diff line number Diff line change
Expand Up @@ -2051,13 +2051,16 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, ulong ar
}
break;
}
case I2ORESETCMD:
if(pHba->host)
spin_lock_irqsave(pHba->host->host_lock, flags);
case I2ORESETCMD: {
struct Scsi_Host *shost = pHba->host;

if (shost)
spin_lock_irqsave(shost->host_lock, flags);
adpt_hba_reset(pHba);
if(pHba->host)
spin_unlock_irqrestore(pHba->host->host_lock, flags);
if (shost)
spin_unlock_irqrestore(shost->host_lock, flags);
break;
}
case I2ORESCANCMD:
adpt_rescan(pHba);
break;
Expand Down

0 comments on commit 7709e9b

Please sign in to comment.