From 728996829b3e2a3bbacb7390e6c040dd839cdf21 Mon Sep 17 00:00:00 2001 From: Mike Christie Date: Thu, 5 Mar 2009 14:46:07 -0600 Subject: [PATCH] [SCSI] libiscsi: fix possbile null ptr session command cleanup If the iscsi eh fires when the current task is a nop, then the task->sc pointer is null. fail_all_commands could then try to do task->sc->device and oops. We actually do not need to access the curr task in this path, because if it is a cmd task the fail_command call will handle this and if it is mgmt task then the flush of the mgmt queues will handle that. Signed-off-by: Mike Christie Signed-off-by: James Bottomley --- drivers/scsi/libiscsi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index d0701791113..dfaa8adf099 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1603,8 +1603,11 @@ static void fail_all_commands(struct iscsi_conn *conn, unsigned lun, { struct iscsi_task *task, *tmp; - if (conn->task && (conn->task->sc->device->lun == lun || lun == -1)) - conn->task = NULL; + if (conn->task) { + if (lun == -1 || + (conn->task->sc && conn->task->sc->device->lun == lun)) + conn->task = NULL; + } /* flush pending */ list_for_each_entry_safe(task, tmp, &conn->xmitqueue, running) { -- 2.41.1