Commit f3181a10 authored by Faisal Latif's avatar Faisal Latif Committed by Roland Dreier

RDMA/nes: Check cqp_avail_reqs is empty after locking the list

Between the first empty list check and locking the list, the list can
change.  Check it again after it is locked to make sure the list is
still not empty.
Signed-off-by: default avatarFaisal Latif <faisal.latif@intel.com>
Signed-off-by: default avatarChien Tung <chien.tin.tung@intel.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent abb77256
...@@ -540,11 +540,14 @@ struct nes_cqp_request *nes_get_cqp_request(struct nes_device *nesdev) ...@@ -540,11 +540,14 @@ struct nes_cqp_request *nes_get_cqp_request(struct nes_device *nesdev)
if (!list_empty(&nesdev->cqp_avail_reqs)) { if (!list_empty(&nesdev->cqp_avail_reqs)) {
spin_lock_irqsave(&nesdev->cqp.lock, flags); spin_lock_irqsave(&nesdev->cqp.lock, flags);
cqp_request = list_entry(nesdev->cqp_avail_reqs.next, if (!list_empty(&nesdev->cqp_avail_reqs)) {
cqp_request = list_entry(nesdev->cqp_avail_reqs.next,
struct nes_cqp_request, list); struct nes_cqp_request, list);
list_del_init(&cqp_request->list); list_del_init(&cqp_request->list);
}
spin_unlock_irqrestore(&nesdev->cqp.lock, flags); spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
} else { }
if (cqp_request == NULL) {
cqp_request = kzalloc(sizeof(struct nes_cqp_request), GFP_KERNEL); cqp_request = kzalloc(sizeof(struct nes_cqp_request), GFP_KERNEL);
if (cqp_request) { if (cqp_request) {
cqp_request->dynamic = 1; cqp_request->dynamic = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment