Skip to content

Commit

Permalink
nvmet-fc: correct use after free on list teardown
Browse files Browse the repository at this point in the history
Use list_for_each_entry_safe to prevent list handling from referencing
next pointers directly after list_del's

Signed-off-by: James Smart <james.smart@broadcom.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
James Smart authored and Christoph Hellwig committed Aug 16, 2017
1 parent 42819eb commit 16a5a48
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/nvme/target/fc.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue)
{
struct nvmet_fc_tgtport *tgtport = queue->assoc->tgtport;
struct nvmet_fc_fcp_iod *fod = queue->fod;
struct nvmet_fc_defer_fcp_req *deferfcp;
struct nvmet_fc_defer_fcp_req *deferfcp, *tempptr;
unsigned long flags;
int i, writedataactive;
bool disconnect;
Expand Down Expand Up @@ -735,7 +735,8 @@ nvmet_fc_delete_target_queue(struct nvmet_fc_tgt_queue *queue)
}

/* Cleanup defer'ed IOs in queue */
list_for_each_entry(deferfcp, &queue->avail_defer_list, req_list) {
list_for_each_entry_safe(deferfcp, tempptr, &queue->avail_defer_list,
req_list) {
list_del(&deferfcp->req_list);
kfree(deferfcp);
}
Expand Down

0 comments on commit 16a5a48

Please sign in to comment.