Skip to content

Commit d39df15

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: iscsi: Have abort handler get ref to conn
If SCSI midlayer is aborting a task when we are tearing down the conn we could free the conn while the abort thread is accessing the conn. This has the abort handler get a ref to the conn so it won't be freed from under it. Note: this is not needed for device/target reset because we are holding the eh_mutex when accessing the conn. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Lee Duncan <[email protected]> Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent b1d19e8 commit d39df15

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/scsi/libiscsi.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,6 +2285,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
22852285
}
22862286

22872287
conn = session->leadconn;
2288+
iscsi_get_conn(conn->cls_conn);
22882289
conn->eh_abort_cnt++;
22892290
age = session->age;
22902291

@@ -2295,9 +2296,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
22952296
ISCSI_DBG_EH(session, "sc completed while abort in progress\n");
22962297

22972298
spin_unlock(&session->back_lock);
2298-
spin_unlock_bh(&session->frwd_lock);
2299-
mutex_unlock(&session->eh_mutex);
2300-
return SUCCESS;
2299+
goto success;
23012300
}
23022301
ISCSI_DBG_EH(session, "aborting [sc %p itt 0x%x]\n", sc, task->itt);
23032302
__iscsi_get_task(task);
@@ -2364,6 +2363,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
23642363
ISCSI_DBG_EH(session, "abort success [sc %p itt 0x%x]\n",
23652364
sc, task->itt);
23662365
iscsi_put_task(task);
2366+
iscsi_put_conn(conn->cls_conn);
23672367
mutex_unlock(&session->eh_mutex);
23682368
return SUCCESS;
23692369

@@ -2373,6 +2373,7 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
23732373
ISCSI_DBG_EH(session, "abort failed [sc %p itt 0x%x]\n", sc,
23742374
task ? task->itt : 0);
23752375
iscsi_put_task(task);
2376+
iscsi_put_conn(conn->cls_conn);
23762377
mutex_unlock(&session->eh_mutex);
23772378
return FAILED;
23782379
}

0 commit comments

Comments
 (0)