f2c6836685
scsipi_xfer structures. When scsipi_execute_xs() calls the driver's scsi_cmd function, it assumes that it can still dereference a pointer to the scsipi_xfer struct. Since scsipi_done() has already been called, which in turn has called scsipi_free_xs(), the struct has already been returned the structure to the pool! In other words, xs->flags has been compromised, but we are still testing it. These changes resolve the problem by doing the following: - In scsipi_execute_xs(), if the hardware driver's scsi_cmd function returns SUCCESSFULLY_QUEUED, set a new flag (SCSI_ASYNCREQ) in xs->flags. Since the request will be handled asynchronously, we will need the scsipi_xfer struct to be freed in scsipi_done(). If the hardware driver's scsi_cmd function returns COMPLETE, we now simply return any actual errors, or 0 if none occurred. (Previously, we may have returned EJUSTRETURN, of which the sole effect was to avoid freeing the scsipi_xfer struct in our caller.) - In scsipi_done(), only free the scsipi_xfer struct for async requests. The contents of the struct will otherwise remain valid until the function that initiated the transfer frees it. With this change, responsibility for freeing the struct now lies in two places, depending on the type of the request: - For synchronous requests, the routine calling scsipi_execute_xs() must clean up. - For asynchronous requests, scsipi_done() cleans up (as it always has). [Note: this change also corrects a problem with sddump(): scsipi_done() was attempting to return a static scsipi_xfer struct to the pool! Since dumps are performed synchronously, we now handle this correctly.] This solution was provided by Jason Thorpe, after I got him to look at some related (but insufficient) attempts of my own. |
||
---|---|---|
.. | ||
atapi_all.h | ||
atapi_base.c | ||
atapi_cd.h | ||
atapi_disk.h | ||
atapiconf.c | ||
atapiconf.h | ||
cd_atapi.c | ||
cd_scsi.c | ||
cd.c | ||
cdvar.h | ||
ch.c | ||
files.scsipi | ||
if_se.c | ||
Makefile | ||
scsi_all.h | ||
scsi_base.c | ||
scsi_cd.h | ||
scsi_changer.h | ||
scsi_ctron_ether.h | ||
scsi_disk.h | ||
scsi_message.h | ||
scsi_scanner.h | ||
scsi_tape.h | ||
scsi_verbose.c | ||
scsiconf.c | ||
scsiconf.h | ||
scsipi_all.h | ||
scsipi_base.c | ||
scsipi_base.h | ||
scsipi_cd.h | ||
scsipi_debug.h | ||
scsipi_disk.h | ||
scsipi_ioctl.c | ||
scsipi_verbose.c | ||
scsipiconf.c | ||
scsipiconf.h | ||
sd_atapi.c | ||
sd_scsi.c | ||
sd.c | ||
sdvar.h | ||
ss_mustek.c | ||
ss_mustek.h | ||
ss_scanjet.c | ||
ss.c | ||
ssvar.h | ||
st.c | ||
su.c | ||
uk.c |