diff options
| -rw-r--r-- | drivers/nvme/target/rdma.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/nvme/target/rdma.c b/drivers/nvme/target/rdma.c index a8d23eb80192..a884e3a0e8af 100644 --- a/drivers/nvme/target/rdma.c +++ b/drivers/nvme/target/rdma.c | |||
| @@ -139,6 +139,10 @@ static void nvmet_rdma_recv_done(struct ib_cq *cq, struct ib_wc *wc); | |||
| 139 | static void nvmet_rdma_read_data_done(struct ib_cq *cq, struct ib_wc *wc); | 139 | static void nvmet_rdma_read_data_done(struct ib_cq *cq, struct ib_wc *wc); |
| 140 | static void nvmet_rdma_qp_event(struct ib_event *event, void *priv); | 140 | static void nvmet_rdma_qp_event(struct ib_event *event, void *priv); |
| 141 | static void nvmet_rdma_queue_disconnect(struct nvmet_rdma_queue *queue); | 141 | static void nvmet_rdma_queue_disconnect(struct nvmet_rdma_queue *queue); |
| 142 | static void nvmet_rdma_free_rsp(struct nvmet_rdma_device *ndev, | ||
| 143 | struct nvmet_rdma_rsp *r); | ||
| 144 | static int nvmet_rdma_alloc_rsp(struct nvmet_rdma_device *ndev, | ||
| 145 | struct nvmet_rdma_rsp *r); | ||
| 142 | 146 | ||
| 143 | static const struct nvmet_fabrics_ops nvmet_rdma_ops; | 147 | static const struct nvmet_fabrics_ops nvmet_rdma_ops; |
| 144 | 148 | ||
| @@ -182,9 +186,17 @@ nvmet_rdma_get_rsp(struct nvmet_rdma_queue *queue) | |||
| 182 | spin_unlock_irqrestore(&queue->rsps_lock, flags); | 186 | spin_unlock_irqrestore(&queue->rsps_lock, flags); |
| 183 | 187 | ||
| 184 | if (unlikely(!rsp)) { | 188 | if (unlikely(!rsp)) { |
| 185 | rsp = kmalloc(sizeof(*rsp), GFP_KERNEL); | 189 | int ret; |
| 190 | |||
| 191 | rsp = kzalloc(sizeof(*rsp), GFP_KERNEL); | ||
| 186 | if (unlikely(!rsp)) | 192 | if (unlikely(!rsp)) |
| 187 | return NULL; | 193 | return NULL; |
| 194 | ret = nvmet_rdma_alloc_rsp(queue->dev, rsp); | ||
| 195 | if (unlikely(ret)) { | ||
| 196 | kfree(rsp); | ||
| 197 | return NULL; | ||
| 198 | } | ||
| 199 | |||
| 188 | rsp->allocated = true; | 200 | rsp->allocated = true; |
| 189 | } | 201 | } |
| 190 | 202 | ||
| @@ -197,6 +209,7 @@ nvmet_rdma_put_rsp(struct nvmet_rdma_rsp *rsp) | |||
| 197 | unsigned long flags; | 209 | unsigned long flags; |
| 198 | 210 | ||
| 199 | if (unlikely(rsp->allocated)) { | 211 | if (unlikely(rsp->allocated)) { |
| 212 | nvmet_rdma_free_rsp(rsp->queue->dev, rsp); | ||
| 200 | kfree(rsp); | 213 | kfree(rsp); |
| 201 | return; | 214 | return; |
| 202 | } | 215 | } |
