===== drivers/scsi/scsi_lib.c 1.63 vs edited ===== --- 1.63/drivers/scsi/scsi_lib.c Tue Jan 28 10:19:35 2003 +++ edited/drivers/scsi/scsi_lib.c Tue Jan 28 12:29:45 2003 @@ -796,6 +796,8 @@ struct Scsi_Device_Template *STpnt; Scsi_Cmnd *SCpnt; Scsi_Device *SDpnt; + int ret; + SDpnt = (Scsi_Device *) q->queuedata; BUG_ON(!SDpnt); @@ -862,8 +864,6 @@ */ if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) { - int ret; - /* * This will do a couple of things: * 1) Fill in the actual SCSI command. @@ -884,19 +884,27 @@ * required). */ if ((ret = scsi_init_io(SCpnt))) - return ret; + goto fail_release_cmd; /* * Initialize the actual SCSI command for this request. */ if (!STpnt->init_command(SCpnt)) { - scsi_release_buffers(SCpnt); - return BLKPREP_KILL; + ret = BLKPREP_KILL; + goto fail_release_buffers; } } /* The request is now prepped, no need to come back here */ req->flags |= REQ_DONTPREP; return BLKPREP_OK; + + fail_release_buffers: + scsi_release_buffers(SCpnt); + + fail_release_cmd: + scsi_put_command(SCpnt); + + return ret; } /*