Skip to content

Commit ed8ec8f

Browse files
author
Nicholas Bellinger
committed
tcm_fc: Fix free-after-use regression in ft_free_cmd
This patch fixes a free-after-use regression in ft_free_cmd(), where ft_sess_put() is called with cmd->sess after percpu_ida_free() has already released the tag. Fix this bug by saving the ft_sess pointer ahead of percpu_ida_free(), and pass it directly to ft_sess_put(). The regression was originally introduced in v3.13-rc1 commit: commit 5f544cf Author: Nicholas Bellinger <[email protected]> Date: Mon Sep 23 12:12:42 2013 -0700 tcm_fc: Convert to per-cpu command map pre-allocation of ft_cmd Reported-by: Jun Wu <[email protected]> Cc: Mark Rustad <[email protected]> Cc: Robert Love <[email protected]> Cc: <[email protected]> #3.13+ Signed-off-by: Nicholas Bellinger <[email protected]>
1 parent 7cbfcc9 commit ed8ec8f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/target/tcm_fc/tfc_cmd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,18 @@ static void ft_free_cmd(struct ft_cmd *cmd)
9090
{
9191
struct fc_frame *fp;
9292
struct fc_lport *lport;
93-
struct se_session *se_sess;
93+
struct ft_sess *sess;
9494

9595
if (!cmd)
9696
return;
97-
se_sess = cmd->sess->se_sess;
97+
sess = cmd->sess;
9898
fp = cmd->req_frame;
9999
lport = fr_dev(fp);
100100
if (fr_seq(fp))
101101
lport->tt.seq_release(fr_seq(fp));
102102
fc_frame_free(fp);
103-
percpu_ida_free(&se_sess->sess_tag_pool, cmd->se_cmd.map_tag);
104-
ft_sess_put(cmd->sess); /* undo get from lookup at recv */
103+
percpu_ida_free(&sess->se_sess->sess_tag_pool, cmd->se_cmd.map_tag);
104+
ft_sess_put(sess); /* undo get from lookup at recv */
105105
}
106106

107107
void ft_release_cmd(struct se_cmd *se_cmd)

0 commit comments

Comments
 (0)