aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Henzl <thenzl@redhat.com>2013-08-01 09:14:00 -0400
committerJames Bottomley <JBottomley@Parallels.com>2013-08-26 04:51:31 -0400
commit2cc5bfaf854463d9d1aa52091f60110fbf102a96 (patch)
treea506db6460685149054a2995770ba5b916bac2fa
parent80aebef7c112ca2610ba8aa6cd8cb02f3828e366 (diff)
[SCSI] hpsa: fix a race in cmd_free/scsi_done
When the driver calls scsi_done and after that frees it's internal preallocated memory it can happen that a new job is enqueud before the memory is freed. The allocation fails and the message "cmd_alloc returned NULL" is shown. Patch below fixes it by moving cmd->scsi_done after cmd_free. Signed-off-by: Tomas Henzl <thenzl@redhat.com> Acked-by: Stephen M. Cameron <scameron@beardog.cce.hp.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/hpsa.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 7f4f790a3d71..21fd2b182ec9 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -1205,8 +1205,8 @@ static void complete_scsi_command(struct CommandList *cp)
1205 scsi_set_resid(cmd, ei->ResidualCnt); 1205 scsi_set_resid(cmd, ei->ResidualCnt);
1206 1206
1207 if (ei->CommandStatus == 0) { 1207 if (ei->CommandStatus == 0) {
1208 cmd->scsi_done(cmd);
1209 cmd_free(h, cp); 1208 cmd_free(h, cp);
1209 cmd->scsi_done(cmd);
1210 return; 1210 return;
1211 } 1211 }
1212 1212
@@ -1379,8 +1379,8 @@ static void complete_scsi_command(struct CommandList *cp)
1379 dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n", 1379 dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n",
1380 cp, ei->CommandStatus); 1380 cp, ei->CommandStatus);
1381 } 1381 }
1382 cmd->scsi_done(cmd);
1383 cmd_free(h, cp); 1382 cmd_free(h, cp);
1383 cmd->scsi_done(cmd);
1384} 1384}
1385 1385
1386static void hpsa_pci_unmap(struct pci_dev *pdev, 1386static void hpsa_pci_unmap(struct pci_dev *pdev,