Skip to contentSkip to conversation

libsas: Check for completed commands before calling lldd_abort_task()

PATCH Superseded Hannes Reinecke 2 participants 3 messages Jan 8, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libsas: Check for completed commands before calling lldd_abort_task()

The abort handler might be racing with command completion, so the task might already be NULL by the time the abort handler is called.

---
 drivers/scsi/libsas/sas_scsi_host.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/libsas/sas_scsi_host.c +3 -2
index 58476b7..ae2ae3c 100644
@@ -486,7 +486,7 @@ static int sas_queue_reset(struct domain_device *dev, int reset_type,
 
 int sas_eh_abort_handler(struct scsi_cmnd *cmd)
 {
-	int res;
+	int res = TMF_RESP_FUNC_COMPLETE;
 	struct sas_task *task = TO_SAS_TASK(cmd);
 	struct Scsi_Host *host = cmd->device->host;
 	struct sas_internal *i = to_sas_internal(host->transportt);
@@ -494,7 +494,8 @@ int sas_eh_abort_handler(struct scsi_cmnd *cmd)
 	if (!i->dft->lldd_abort_task)
 		return FAILED;
 
-	res = i->dft->lldd_abort_task(task);
+	if (task)
+		res = i->dft->lldd_abort_task(task);
 	if (res == TMF_RESP_FUNC_SUCC || res == TMF_RESP_FUNC_COMPLETE)
 		return SUCCESS;
 
Signature · 1 line
1.8.5.6
#1 lore raw
Quoted 2 lines · Hannes Reinecke

The abort handler might be racing with command completion, so the task might already be NULL by the time the abort handler is called.

But without taking dev_done_lock (or using cmpxchg) what prevents use from still hitting this, although in a more narrow window?

#2 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 2 lines · Hannes Reinecke

The abort handler might be racing with command completion, so the task might already be NULL by the time the abort handler is called.

But without taking dev_done_lock (or using cmpxchg) what prevents use from still hitting this, although in a more narrow window?

Good point.
Will be updating the patch.

Cheers,

Hannes

Signature · 5 lines
Dr. Hannes Reinecke		   Teamlead Storage & Networking
[email protected]			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)