mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-11 13:27:06 +09:00
target: Fix NULL pointer dereference for XCOPY in target_put_sess_cmd
commit0ed6e189e3upstream. This patch fixes a NULL pointer dereference regression bug that was introduced with: commit1e1110c43bAuthor: 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> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
563d554669
commit
af653349f7
@@ -2407,6 +2407,10 @@ static void target_release_cmd_kref(struct kref *kref)
|
||||
*/
|
||||
int target_put_sess_cmd(struct se_session *se_sess, struct se_cmd *se_cmd)
|
||||
{
|
||||
if (!se_sess) {
|
||||
se_cmd->se_tfo->release_cmd(se_cmd);
|
||||
return 1;
|
||||
}
|
||||
return kref_put_spinlock_irqsave(&se_cmd->cmd_kref, target_release_cmd_kref,
|
||||
&se_sess->sess_cmd_lock);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user