summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/megaraid
diff options
context:
space:
mode:
authoradam radford <aradford@gmail.com>2011-10-13 19:01:12 -0400
committerJames Bottomley <JBottomley@Parallels.com>2011-10-20 11:18:17 -0400
commitf575c5d3ebdca3b0482847d8fcba971767754a9e (patch)
tree8f238a30ea2a4d0a9300466e60a8bae85280fd6d /drivers/scsi/megaraid
parentfba63097b8614a4a158226c02eec0318f41cd24f (diff)
[SCSI] megaraid_sas: Fix instance access in megasas_reset_timer
The following patch for megaraid_sas will fix a potential bad pointer access in megasas_reset_timer(), when a MegaRAID 9265/9285 or 9360/9380 gets a timeout. megasas_build_io_fusion() sets SCp.ptr to be a struct megasas_cmd_fusion *, but then megasas_reset_timer() was casting SCp.ptr to be a struct megasas_cmd *, then trying to access cmd->instance, which is invalid. Just loading instance from scmd->device->host->hostdata in megasas_reset_timer() fixes the issue. Signed-off-by: Adam Radford <aradford@gmail.com> Cc: stable@kernel.org Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/megaraid')
-rw-r--r--drivers/scsi/megaraid/megaraid_sas_base.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 8d587cb73cb7..29a994f9c4f1 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1914,7 +1914,6 @@ static int megasas_generic_reset(struct scsi_cmnd *scmd)
1914static enum 1914static enum
1915blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd) 1915blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
1916{ 1916{
1917 struct megasas_cmd *cmd = (struct megasas_cmd *)scmd->SCp.ptr;
1918 struct megasas_instance *instance; 1917 struct megasas_instance *instance;
1919 unsigned long flags; 1918 unsigned long flags;
1920 1919
@@ -1923,7 +1922,7 @@ blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
1923 return BLK_EH_NOT_HANDLED; 1922 return BLK_EH_NOT_HANDLED;
1924 } 1923 }
1925 1924
1926 instance = cmd->instance; 1925 instance = (struct megasas_instance *)scmd->device->host->hostdata;
1927 if (!(instance->flag & MEGASAS_FW_BUSY)) { 1926 if (!(instance->flag & MEGASAS_FW_BUSY)) {
1928 /* FW is busy, throttle IO */ 1927 /* FW is busy, throttle IO */
1929 spin_lock_irqsave(instance->host->host_lock, flags); 1928 spin_lock_irqsave(instance->host->host_lock, flags);