Skip to content

Commit a0421da

Browse files
committed
Merge branch '3.4-rc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
Pull target fixes from Nicholas Bellinger: "Pull two tcm_fc fabric related fixes for -rc2: Note that both have been CC'ed to stable, and patch #1 is the important one that addresses a memory corruption bug related to FC exchange timeouts + command abort. Thanks again to MDR for tracking down this issue!" * '3.4-rc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending: tcm_fc: Do not free tpg structure during wq allocation failure tcm_fc: Add abort flag for gracefully handling exchange timeout
2 parents 4157368 + 06383f1 commit a0421da

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

drivers/target/tcm_fc/tcm_fc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ struct ft_cmd {
122122
/* Local sense buffer */
123123
unsigned char ft_sense_buffer[TRANSPORT_SENSE_BUFFER];
124124
u32 was_ddp_setup:1; /* Set only if ddp is setup */
125+
u32 aborted:1; /* Set if aborted by reset or timeout */
125126
struct scatterlist *sg; /* Set only if DDP is setup */
126127
u32 sg_cnt; /* No. of item in scatterlist */
127128
};

drivers/target/tcm_fc/tfc_cmd.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ int ft_queue_status(struct se_cmd *se_cmd)
121121
struct fc_exch *ep;
122122
size_t len;
123123

124+
if (cmd->aborted)
125+
return 0;
124126
ft_dump_cmd(cmd, __func__);
125127
ep = fc_seq_exch(cmd->seq);
126128
lport = ep->lp;
@@ -187,6 +189,8 @@ int ft_write_pending(struct se_cmd *se_cmd)
187189

188190
ft_dump_cmd(cmd, __func__);
189191

192+
if (cmd->aborted)
193+
return 0;
190194
ep = fc_seq_exch(cmd->seq);
191195
lport = ep->lp;
192196
fp = fc_frame_alloc(lport, sizeof(*txrdy));
@@ -252,10 +256,10 @@ static void ft_recv_seq(struct fc_seq *sp, struct fc_frame *fp, void *arg)
252256
struct ft_cmd *cmd = arg;
253257
struct fc_frame_header *fh;
254258

255-
if (IS_ERR(fp)) {
259+
if (unlikely(IS_ERR(fp))) {
256260
/* XXX need to find cmd if queued */
257261
cmd->seq = NULL;
258-
transport_generic_free_cmd(&cmd->se_cmd, 0);
262+
cmd->aborted = true;
259263
return;
260264
}
261265

@@ -399,6 +403,8 @@ int ft_queue_tm_resp(struct se_cmd *se_cmd)
399403
struct se_tmr_req *tmr = se_cmd->se_tmr_req;
400404
enum fcp_resp_rsp_codes code;
401405

406+
if (cmd->aborted)
407+
return 0;
402408
switch (tmr->response) {
403409
case TMR_FUNCTION_COMPLETE:
404410
code = FCP_TMF_CMPL;

drivers/target/tcm_fc/tfc_conf.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ static struct se_portal_group *ft_add_tpg(
300300
{
301301
struct ft_lport_acl *lacl;
302302
struct ft_tpg *tpg;
303+
struct workqueue_struct *wq;
303304
unsigned long index;
304305
int ret;
305306

@@ -321,18 +322,20 @@ static struct se_portal_group *ft_add_tpg(
321322
tpg->lport_acl = lacl;
322323
INIT_LIST_HEAD(&tpg->lun_list);
323324

324-
ret = core_tpg_register(&ft_configfs->tf_ops, wwn, &tpg->se_tpg,
325-
tpg, TRANSPORT_TPG_TYPE_NORMAL);
326-
if (ret < 0) {
325+
wq = alloc_workqueue("tcm_fc", 0, 1);
326+
if (!wq) {
327327
kfree(tpg);
328328
return NULL;
329329
}
330330

331-
tpg->workqueue = alloc_workqueue("tcm_fc", 0, 1);
332-
if (!tpg->workqueue) {
331+
ret = core_tpg_register(&ft_configfs->tf_ops, wwn, &tpg->se_tpg,
332+
tpg, TRANSPORT_TPG_TYPE_NORMAL);
333+
if (ret < 0) {
334+
destroy_workqueue(wq);
333335
kfree(tpg);
334336
return NULL;
335337
}
338+
tpg->workqueue = wq;
336339

337340
mutex_lock(&ft_lport_lock);
338341
list_add_tail(&tpg->list, &lacl->tpg_list);

drivers/target/tcm_fc/tfc_io.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ int ft_queue_data_in(struct se_cmd *se_cmd)
8181
void *from;
8282
void *to = NULL;
8383

84+
if (cmd->aborted)
85+
return 0;
8486
ep = fc_seq_exch(cmd->seq);
8587
lport = ep->lp;
8688
cmd->seq = lport->tt.seq_start_next(cmd->seq);

0 commit comments

Comments
 (0)