Skip to contentSkip to conversation

qla2xxx: Fix NULL pointer dereference

PATCH In review Jörn Engel 2 participants 2 messages Feb 17, 2012 – Feb 18, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qla2xxx: Fix NULL pointer dereference

Afaics the assignment does not need to be protected by ha->tgt_mutex and we definitely should check for NULL before dereferencing sess.

---
 drivers/scsi/qla2xxx/qla_target.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/qla2xxx/qla_target.c +1 -1
index ac203ef..4bbfa88 100644
@@ -2586,12 +2586,12 @@ static void qla_tgt_do_work(struct work_struct *work)
 
 		mutex_lock(&ha->tgt_mutex);
 		cmd->sess = sess = qla_tgt_make_local_sess(vha, s_id, loop_id);
-		cmd->loop_id = sess->loop_id;
 		/* sess has got an extra creation ref */
 		mutex_unlock(&ha->tgt_mutex);
 
 		if (!sess)
 			goto out_term;
+		cmd->loop_id = sess->loop_id;
 	}
 
 	if (tgt->tgt_stop)
Signature · 1 line
1.7.8.3
#1 lore raw
Quoted 13 lines · Jörn Engel

Afaics the assignment does not need to be protected by ha->tgt_mutex and we definitely should check for NULL before dereferencing sess.

---
 drivers/scsi/qla2xxx/qla_target.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/qla2xxx/qla_target.c +0 -0
index ac203ef..4bbfa88 100644

drivers/scsi/qla2xxx/qla_target.c static void qla_tgt_do_work(struct work_struct *work) · line 2594

Quoted 10 lines
drivers/scsi/qla2xxx/qla_target.c +1 -1
@@ -2586,12 +2586,12 @@ static void qla_tgt_do_work(struct work_struct *work)
 
                mutex_lock(&ha->tgt_mutex);
                cmd->sess = sess = qla_tgt_make_local_sess(vha, s_id, loop_id);
-               cmd->loop_id = sess->loop_id;
                /* sess has got an extra creation ref */
                mutex_unlock(&ha->tgt_mutex);
 
                if (!sess)
                        goto out_term;
+               cmd->loop_id = sess->loop_id;

Good catch... maybe it's cleaner if we just use the loop_id local variable we already have anyway? (Not that it really matters either way)