]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
RDMA/nes: Check cqp_avail_reqs is empty after locking the list
authorFaisal Latif <faisal.latif@intel.com>
Sat, 22 Nov 2008 02:50:55 +0000 (20:50 -0600)
committerRoland Dreier <rolandd@cisco.com>
Fri, 5 Dec 2008 19:00:24 +0000 (11:00 -0800)
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: Faisal Latif <faisal.latif@intel.com>
Signed-off-by: Chien Tung <chien.tin.tung@intel.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/hw/nes/nes_utils.c

index fb8cbd71a2ef86b17b98539a471e0c4d7bf7b409..5611a73d5831395f61e57559cd972f9949b726c0 100644 (file)
@@ -540,11 +540,14 @@ struct nes_cqp_request *nes_get_cqp_request(struct nes_device *nesdev)
 
        if (!list_empty(&nesdev->cqp_avail_reqs)) {
                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);
-               list_del_init(&cqp_request->list);
+                       list_del_init(&cqp_request->list);
+               }
                spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
-       } else {
+       }
+       if (cqp_request == NULL) {
                cqp_request = kzalloc(sizeof(struct nes_cqp_request), GFP_KERNEL);
                if (cqp_request) {
                        cqp_request->dynamic = 1;