Skip to content

Commit 0d2bdf9

Browse files
bvanasscheChristoph Hellwig
authored andcommitted
nvme-fc: rework the request initialization code
Instead of setting and then clearing the first_sgl pointer for AEN requests, leave that pointer zero. This patch does not change how requests are initialized but avoids that Coverity reports the following complaint for nvme_fc_init_aen_ops(): CID 1418400 (#1 of 1): Out-of-bounds access (OVERRUN) 4. overrun-buffer-val: Overrunning buffer pointed to by aen_op of 312 bytes by passing it to a function which accesses it at byte offset 312. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: James Smart <james.smart@broadcom.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
1 parent d3d0bc7 commit 0d2bdf9

File tree

1 file changed

+6
-3
lines changed
  • drivers/nvme/host

1 file changed

+6
-3
lines changed

drivers/nvme/host/fc.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,6 @@ __nvme_fc_init_request(struct nvme_fc_ctrl *ctrl,
17041704
op->fcp_req.rspaddr = &op->rsp_iu;
17051705
op->fcp_req.rsplen = sizeof(op->rsp_iu);
17061706
op->fcp_req.done = nvme_fc_fcpio_done;
1707-
op->fcp_req.first_sgl = &op_w_sgl->sgl[0];
17081707
op->fcp_req.private = &op->fcp_req.first_sgl[SG_CHUNK_SIZE];
17091708
op->ctrl = ctrl;
17101709
op->queue = queue;
@@ -1746,9 +1745,14 @@ nvme_fc_init_request(struct blk_mq_tag_set *set, struct request *rq,
17461745
struct nvme_fcp_op_w_sgl *op = blk_mq_rq_to_pdu(rq);
17471746
int queue_idx = (set == &ctrl->tag_set) ? hctx_idx + 1 : 0;
17481747
struct nvme_fc_queue *queue = &ctrl->queues[queue_idx];
1748+
int res;
17491749

17501750
nvme_req(rq)->ctrl = &ctrl->ctrl;
1751-
return __nvme_fc_init_request(ctrl, queue, &op->op, rq, queue->rqcnt++);
1751+
res = __nvme_fc_init_request(ctrl, queue, &op->op, rq, queue->rqcnt++);
1752+
if (res)
1753+
return res;
1754+
op->op.fcp_req.first_sgl = &op->sgl[0];
1755+
return res;
17521756
}
17531757

17541758
static int
@@ -1778,7 +1782,6 @@ nvme_fc_init_aen_ops(struct nvme_fc_ctrl *ctrl)
17781782
}
17791783

17801784
aen_op->flags = FCOP_FLAGS_AEN;
1781-
aen_op->fcp_req.first_sgl = NULL; /* no sg list */
17821785
aen_op->fcp_req.private = private;
17831786

17841787
memset(sqe, 0, sizeof(*sqe));

0 commit comments

Comments
 (0)