diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2009-07-02 18:50:38 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2009-07-02 18:50:38 +0000 |
commit | 2183ff880058608bbd89e826f874c4a7e085e2c0 (patch) | |
tree | 79786dfd9d9ed316802ff62d37173eb2e64854bb /sys/dev | |
parent | 89cfa4a84a2affee8396212e8520a62afb7be887 (diff) |
Revert the 'optimization' I attempted in r1.21 since it turns out
that returning COMPLETE for non-SCSI_POLL commands is significant.
Fixes double free of xs and subsequent crashes caused by pulling
out USB media while i/o is active. Problem analyzed & fix discovered
by hshoexer@. A more general fix may follow post-4.6.
ok miod@ deraadt@.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/umass_scsi.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/dev/usb/umass_scsi.c b/sys/dev/usb/umass_scsi.c index e8d6d469822..8ba3073ee9f 100644 --- a/sys/dev/usb/umass_scsi.c +++ b/sys/dev/usb/umass_scsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umass_scsi.c,v 1.24 2009/02/16 21:19:07 miod Exp $ */ +/* $OpenBSD: umass_scsi.c,v 1.25 2009/07/02 18:50:37 krw Exp $ */ /* $NetBSD: umass_scsipi.c,v 1.9 2003/02/16 23:14:08 augustss Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -173,7 +173,7 @@ umass_scsi_cmd(struct scsi_xfer *xs) struct umass_softc *sc = sc_link->adapter_softc; struct scsi_generic *cmd; - int cmdlen, dir, s; + int cmdlen, dir, rslt, s; #ifdef UMASS_DEBUG microtime(&sc->tv); @@ -263,10 +263,16 @@ umass_scsi_cmd(struct scsi_xfer *xs) /* Return if command finishes early. */ done: xs->flags |= ITSDONE; + if (xs->flags & SCSI_POLL) + rslt = COMPLETE; + else + rslt = SUCCESSFULLY_QUEUED; + s = splbio(); scsi_done(xs); splx(s); - return (COMPLETE); + + return (rslt); } void |