aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <roland@purestorage.com>2012-06-11 21:23:16 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2012-06-12 23:12:26 -0400
commitfae9eaf81323eda64f28b9f4f4aeffb807e5b5f4 (patch)
tree3fc7f7eecc6620f5b8aa2ad2a5e9d50aa9a1be12
parent092e1dc3f227ebef9ad45c26ef05c283ca4495a5 (diff)
qla2xxx: Don't leak commands we give up on in qlt_do_work()
If we go to the "out_term:" exit path in qlt_do_work(), we call qlt_send_term_exchange() with a NULL cmd, which means that it can't possibly free the cmd for us. Add an explicit call to free the command memory, so we don't leak the allocation. This will also fix warnings about "BUG qla_tgt_cmd_cachep: Objects remaining on kmem_cache_close" from slub when unloading the qla2xxx target module. Signed-off-by: Roland Dreier <roland@purestorage.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/scsi/qla2xxx/qla_target.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index c263f9016deb..e91292099a09 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -2725,10 +2725,12 @@ static void qlt_do_work(struct work_struct *work)
2725out_term: 2725out_term:
2726 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf020, "Terminating work cmd %p", cmd); 2726 ql_dbg(ql_dbg_tgt_mgt, vha, 0xf020, "Terminating work cmd %p", cmd);
2727 /* 2727 /*
2728 * cmd has not sent to target yet, so pass NULL as the second argument 2728 * cmd has not sent to target yet, so pass NULL as the second
2729 * argument to qlt_send_term_exchange() and free the memory here.
2729 */ 2730 */
2730 spin_lock_irqsave(&ha->hardware_lock, flags); 2731 spin_lock_irqsave(&ha->hardware_lock, flags);
2731 qlt_send_term_exchange(vha, NULL, &cmd->atio, 1); 2732 qlt_send_term_exchange(vha, NULL, &cmd->atio, 1);
2733 kmem_cache_free(qla_tgt_cmd_cachep, cmd);
2732 spin_unlock_irqrestore(&ha->hardware_lock, flags); 2734 spin_unlock_irqrestore(&ha->hardware_lock, flags);
2733 if (sess) 2735 if (sess)
2734 ha->tgt.tgt_ops->put_sess(sess); 2736 ha->tgt.tgt_ops->put_sess(sess);