]> Git Repo - linux.git/commitdiff
target: Fix NULL pointer dereference for XCOPY in target_put_sess_cmd
authorNicholas Bellinger <[email protected]>
Thu, 12 Jun 2014 19:45:02 +0000 (12:45 -0700)
committerNicholas Bellinger <[email protected]>
Thu, 12 Jun 2014 19:45:02 +0000 (12:45 -0700)
This patch fixes a NULL pointer dereference regression bug that was
introduced with:

commit 1e1110c43b1cda9fe77fc4a04835e460550e6b3c
Author: Mikulas Patocka <[email protected]>
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 <[email protected]>
Cc: Thomas Glanzmann <[email protected]>
Cc: Mikulas Patocka <[email protected]>
Cc: [email protected] # 3.12+
Signed-off-by: Nicholas Bellinger <[email protected]>
drivers/target/target_core_transport.c

index c9e8b35a954f3a72d9c35793526e7bceb02fd090..4ef11145c746d64651b0a17624879575f8178b9e 100644 (file)
@@ -2424,6 +2424,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);
 }
This page took 0.067135 seconds and 4 git commands to generate.