RDMA/uverbs: Initialize cq_context appropriately
authorBharat Potnuri <bharat@chelsio.com>
Tue, 1 Aug 2017 05:28:35 +0000 (10:58 +0530)
committerDoug Ledford <dledford@redhat.com>
Tue, 22 Aug 2017 17:55:47 +0000 (13:55 -0400)
Initializing cq_context with ev_queue in create_cq(), leads to NULL pointer
dereference in ib_uverbs_comp_handler(), if application doesnot use completion
channel. This patch fixes the cq_context initialization.

Fixes: 1e7710f3f65 ("IB/core: Change completion channel to use the reworked")
Cc: stable@vger.kernel.org # 4.12
Signed-off-by: Potnuri Bharat Teja <bharat@chelsio.com>
Reviewed-by: Matan Barak <matanb@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
(cherry picked from commit 699a2d5b1b880b4e4e1c7d55fa25659322cf5b51)

drivers/infiniband/core/uverbs_cmd.c

index c551d2b275fdf339310a087bef9c6e821d7c7e09..55822ae7195519c5f86e3f5c32e4f0be3724e2f5 100644 (file)
@@ -1015,7 +1015,7 @@ static struct ib_ucq_object *create_cq(struct ib_uverbs_file *file,
        cq->uobject       = &obj->uobject;
        cq->comp_handler  = ib_uverbs_comp_handler;
        cq->event_handler = ib_uverbs_cq_event_handler;
-       cq->cq_context    = &ev_file->ev_queue;
+       cq->cq_context    = ev_file ? &ev_file->ev_queue : NULL;
        atomic_set(&cq->usecnt, 0);
 
        obj->uobject.object = cq;