From patchwork Tue Aug 1 05:28:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Potnuri Bharat Teja X-Patchwork-Id: 9873687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D48A960365 for ; Tue, 1 Aug 2017 05:28:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C412E1FF28 for ; Tue, 1 Aug 2017 05:28:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6F1F205A8; Tue, 1 Aug 2017 05:28:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 243731FF28 for ; Tue, 1 Aug 2017 05:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750763AbdHAF2v (ORCPT ); Tue, 1 Aug 2017 01:28:51 -0400 Received: from stargate.chelsio.com ([12.32.117.8]:9759 "EHLO stargate.chelsio.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750716AbdHAF2v (ORCPT ); Tue, 1 Aug 2017 01:28:51 -0400 Received: from localhost ([10.193.186.242]) by stargate.chelsio.com (8.13.8/8.13.8) with ESMTP id v715Sceu025131; Mon, 31 Jul 2017 22:28:42 -0700 From: Potnuri Bharat Teja To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, bharat@chelsio.com, swise@opengridcomputing.com Subject: [PATCH 1/1] RDMA/uverbs: Initialize cq_context appropriately Date: Tue, 1 Aug 2017 10:58:35 +0530 Message-Id: <1501565315-3183-1-git-send-email-bharat@chelsio.com> X-Mailer: git-send-email 2.5.3 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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") Signed-off-by: Potnuri Bharat Teja Reviewed-by: Matan Barak --- drivers/infiniband/core/uverbs_cmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 2c98533a0203..8c829522d8c4 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -1015,7 +1015,8 @@ 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 = (cmd->comp_channel >= 0) ? + &ev_file->ev_queue : NULL; atomic_set(&cq->usecnt, 0); obj->uobject.object = cq;