]> git.baikalelectronics.ru Git - kernel.git/commit
target: Fix NULL pointer dereference for XCOPY in target_put_sess_cmd
authorNicholas Bellinger <nab@linux-iscsi.org>
Thu, 12 Jun 2014 19:45:02 +0000 (12:45 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Thu, 12 Jun 2014 19:45:02 +0000 (12:45 -0700)
commit1c34ea6fa7a492a940e38a09fcd5164076491e33
tree934fe69ad3de329696eb4cdb44126e749fa0f78f
parenta799d04b18e16c3f33f95f5e78549fa4c7c65017
target: Fix NULL pointer dereference for XCOPY in target_put_sess_cmd

This patch fixes a NULL pointer dereference regression bug that was
introduced with:

commit dc9721c642091354311126b44ecd8427041a4d3d
Author: Mikulas Patocka <mpatocka@redhat.com>
Date:   Sat May 17 06:49:22 2014 -0400

    target: fix memory leak on XCOPY

Now that target_put_sess_cmd() -> kref_put_spinlock_irqsave() is
called with a valid se_cmd->cmd_kref, a NULL pointer dereference
is triggered because the XCOPY passthrough commands don't have
an associated se_session pointer.

To address this bug, go ahead and checking for a NULL se_sess pointer
within target_put_sess_cmd(), and call se_cmd->se_tfo->release_cmd()
to release the XCOPY's xcopy_pt_cmd memory.

Reported-by: Thomas Glanzmann <thomas@glanzmann.de>
Cc: Thomas Glanzmann <thomas@glanzmann.de>
Cc: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org # 3.12+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_transport.c