aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradam radford <aradford@gmail.com>2011-10-13 19:01:12 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-11-11 12:35:24 -0500
commit20e801924287a2eebe00395f4cebc8eeb7d5aa62 (patch)
tree73787d768577fabcaf0069935f243bd653a9b57b
parent95bf50db41fbb1db306b3e636d46ce9014482a50 (diff)
megaraid_sas: Fix instance access in megasas_reset_timer
commit f575c5d3ebdca3b0482847d8fcba971767754a9e upstream. 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> Signed-off-by: James Bottomley <JBottomley@Parallels.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-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 2d8cdce7b2f..e6e30f4da1f 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -1906,7 +1906,6 @@ static int megasas_generic_reset(struct scsi_cmnd *scmd)
1906static enum 1906static enum
1907blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd) 1907blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
1908{ 1908{
1909 struct megasas_cmd *cmd = (struct megasas_cmd *)scmd->SCp.ptr;
1910 struct megasas_instance *instance; 1909 struct megasas_instance *instance;
1911 unsigned long flags; 1910 unsigned long flags;
1912 1911
@@ -1915,7 +1914,7 @@ blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd)
1915 return BLK_EH_NOT_HANDLED; 1914 return BLK_EH_NOT_HANDLED;
1916 } 1915 }
1917 1916
1918 instance = cmd->instance; 1917 instance = (struct megasas_instance *)scmd->device->host->hostdata;
1919 if (!(instance->flag & MEGASAS_FW_BUSY)) { 1918 if (!(instance->flag & MEGASAS_FW_BUSY)) {
1920 /* FW is busy, throttle IO */ 1919 /* FW is busy, throttle IO */
1921 spin_lock_irqsave(instance->host->host_lock, flags); 1920 spin_lock_irqsave(instance->host->host_lock, flags);