Skip to content

Commit

Permalink
nvmet-rdma: Fix use after free
Browse files Browse the repository at this point in the history
Avoid dereferencing the queue pointer in nvmet_rdma_release_queue_work()
after it has been freed by nvmet_rdma_free_queue().

Fixes: d8f7750 ("nvmet-rdma: Correctly handle RDMA device hot removal")
Signed-off-by: Vincent Stehlé <vincent.stehle@intel.com>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
  • Loading branch information
Vincent Stehlé authored and Sagi Grimberg committed Aug 16, 2016
1 parent 39bbee4 commit 3256aae
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/nvme/target/rdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,10 +978,11 @@ static void nvmet_rdma_release_queue_work(struct work_struct *w)
container_of(w, struct nvmet_rdma_queue, release_work);
struct rdma_cm_id *cm_id = queue->cm_id;
struct nvmet_rdma_device *dev = queue->dev;
enum nvmet_rdma_queue_state state = queue->state;

nvmet_rdma_free_queue(queue);

if (queue->state != NVMET_RDMA_IN_DEVICE_REMOVAL)
if (state != NVMET_RDMA_IN_DEVICE_REMOVAL)
rdma_destroy_id(cm_id);

kref_put(&dev->ref, nvmet_rdma_free_dev);
Expand Down

0 comments on commit 3256aae

Please sign in to comment.