Skip to contentSkip to conversation

fix for ide-scsi crash

PATCH In review [email protected] 2 participants 2 messages Jan 19, 2004 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix for ide-scsi crash

A rather reproducible crash with ide-scsi that I reported yesterday is fixed by the patch below.

(Most of this is just polishing that emacs did while my eyes looked at the code. The only change is not doing

       ide_do_drive_cmd (drive, rq, ide_end);
       spin_lock_irq(cmd->device->host->host_lock);

since cmd may be freed already.)

Andries

[With this in place I wrote three times 640 MB to floptical and diffed; no problems occurred. Without it the system would crash each time.]

drivers/ide/ide-io.c +1 -1
diff -u --recursive --new-file -X /linux/dontdiff a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
@@ -1300,7 +1300,7 @@
  *	Initialize a request before we fill it in and send it down to
  *	ide_do_drive_cmd. Commands must be set up by this function. Right
  *	now it doesn't do a lot, but if that changes abusers will have a
- *	nasty suprise.
+ *	nasty surprise.
  */
 
 void ide_init_drive_cmd (struct request *rq)
drivers/scsi/ide-scsi.c +25 -16

87 lines not on this page · raw message

#1 lore raw

drivers/scsi/ide-scsi.c line 853

Quoted 9 lines · Andries.Brouwer
drivers/scsi/ide-scsi.c +6 -3
-	spin_unlock_irq(cmd->device->host->host_lock);
-	(void) ide_do_drive_cmd (drive, rq, ide_end);
-	spin_lock_irq(cmd->device->host->host_lock);
+	{
+		struct Scsi_Host *host = cmd->device->host;
+		spin_unlock_irq(host->host_lock);
+		(void) ide_do_drive_cmd(drive, rq, ide_end);
+		spin_lock_irq(host->host_lock);
+	}

Interesting. So cmd->device->host changed after ide_do_drive_cmd?

That may be a problem if the scsi error handler has to spring into action for this command, as it uses that field extensively...

drivers/scsi/ide-scsi.c line 857

Quoted 4 lines
drivers/scsi/ide-scsi.c +2 -2
-	if (pc) kfree (pc);
-	if (rq) kfree (rq);
+	kfree (pc);
+	kfree (rq);

So it is OK to rely on the NULL check in kfree?

Thanks, Willem Riede.