public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: Double completion on retry
@ 2013-05-02  8:31 Hannes Reinecke
  2013-05-02  8:34 ` Hannes Reinecke
  0 siblings, 1 reply; 2+ messages in thread
From: Hannes Reinecke @ 2013-05-02  8:31 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-scsi, Hannes Reinecke, Mike Christie, Tejun Heo

When blk_end_request() returns 'false' in scsi_end_request the
request is invalid after blk_end_request_all(). So we must not
return the then stale request pointer. Doing so will result
in a potential double completion.
And we should be calling scsi_release_buffers() before
blk_end_request_all().

Cc: Mike Christie <michaelc@cs.wisc.edu>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index c31187d..8dba66b 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -581,9 +581,11 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int error,
 	 */
 	if (blk_end_request(req, error, bytes)) {
 		/* kill remainder if no retrys */
-		if (error && scsi_noretry_cmd(cmd))
+		if (error && scsi_noretry_cmd(cmd)) {
+			scsi_release_buffers(cmd);
 			blk_end_request_all(req, error);
-		else {
+			cmd = NULL;
+		} else {
 			if (requeue) {
 				/*
 				 * Bleah.  Leftovers again.  Stick the

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-05-02  8:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-02  8:31 [PATCH] scsi: Double completion on retry Hannes Reinecke
2013-05-02  8:34 ` Hannes Reinecke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox