From patchwork Wed Jul 25 20:10:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Heib X-Patchwork-Id: 10544633 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8243114E2 for ; Wed, 25 Jul 2018 20:11:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71A342AB83 for ; Wed, 25 Jul 2018 20:11:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65BFD2ABA0; Wed, 25 Jul 2018 20:11:15 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 124D42AB83 for ; Wed, 25 Jul 2018 20:11:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730370AbeGYVY2 (ORCPT ); Wed, 25 Jul 2018 17:24:28 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34547 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730357AbeGYVY2 (ORCPT ); Wed, 25 Jul 2018 17:24:28 -0400 Received: by mail-wr1-f68.google.com with SMTP id c13-v6so8550241wrt.1 for ; Wed, 25 Jul 2018 13:11:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LZuIWOkIYZIgXw6a1GT1q2yvb53ph+oeAcIr6xk7oO8=; b=gcz+syV/e+FoWG2ZnmMPlauo0XMdLqPC2n5kT7CLlbE+uFItVvL54QIzCNp4pqv5LW sb+WwOmkShBU4umRUC4uEWylDpSsIjzCzI71Q10/mWNV13Z1uOjKJNlHfZG2CQG4UgSd 21Cjl8W7dGlYvtOIfhtvVwj2XtgLy+7ZPuU+jMklK5VDqo1FYMaUYsIg+ahKHDgDLm3o dRM9BUljl8fs+shxUiDO41F/wxxgw5/xQQTGS2fGcTPJLsy8BeIRr8GFpdRjimOtu8iu 2uh5NL8AI7wV+X4clFAx5i4UtZWm23ulBdmmMSJBioddNhJuIzayS9cRGDLJC+jbZFdJ q1Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LZuIWOkIYZIgXw6a1GT1q2yvb53ph+oeAcIr6xk7oO8=; b=r3DoxPSo4qlpkJ0pWsT0N3rmf7/d9l/I7B6CXLlZQr9IhHPrZw69rviarXQ/SXGNc/ iDbkyT41QcD3uBgSkknc1V4vVFk8CUod0hTQIl4Qy+LXt2y3gd9fuOQG2lGmhQ820EiC bem7sNOIQArcvbXf7LgeZNnlZpge0SrfA7e5PWUQYxhX3zbQTNBInvtrAmHNYqUlAoRM IWjKYxx1DLsuBU78ZmqS6GOLRF7dbbaw0TmOmf7Z1sUxZccf7vl6bohGapdGqGEH4mGO PiwFyvBiyOOynbC7TEW2Su3ci7I6YxeKGOdDp7MvkHazVC8YXeOvUDYQesG/wSq5yrtH VTBA== X-Gm-Message-State: AOUpUlGPj9fjxUXC0ta+cVdpDBagnd1YaqA9iZyj1rqxQFa3ah7LFDmH +r3BGglvUB2LL5EB6Ex//uI= X-Google-Smtp-Source: AAOMgpcG8P/67WVc7uHfRrqcwjjwnqncRO2K9rHUcsJGmW5hHdQc0ZpHK5kULUeFXj2qDiSpD5G+Dw== X-Received: by 2002:adf:8062:: with SMTP id 89-v6mr14488477wrk.221.1532549471553; Wed, 25 Jul 2018 13:11:11 -0700 (PDT) Received: from localhost.localdomain (bzq-109-64-56-95.red.bezeqint.net. [109.64.56.95]) by smtp.gmail.com with ESMTPSA id d26-v6sm3708629wmb.15.2018.07.25.13.11.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Jul 2018 13:11:11 -0700 (PDT) From: Kamal Heib To: Doug Ledford , Jason Gunthorpe , Leon Romanovsky , Shiraz Saleem Cc: linux-rdma@vger.kernel.org, Kamal Heib Subject: [PATCH rdma-next v3 2/3] RDMA/core: Check for verbs callbacks before using them Date: Wed, 25 Jul 2018 23:10:44 +0300 Message-Id: <20180725201045.26995-3-kamalheib1@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180725201045.26995-1-kamalheib1@gmail.com> References: <20180725201045.26995-1-kamalheib1@gmail.com> 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 Make sure the providers implement the verbs callbacks before calling them, otherwise return -EOPNOTSUPP. Signed-off-by: Kamal Heib Reviewed-by: Leon Romanovsky --- drivers/infiniband/core/uverbs_cmd.c | 3 ++- drivers/infiniband/core/verbs.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 987ee38ab4b3..c3661ba8a28e 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -2507,7 +2507,8 @@ ssize_t ib_uverbs_post_srq_recv(struct ib_uverbs_file *file, goto out; resp.bad_wr = 0; - ret = srq->device->post_srq_recv(srq, wr, &bad_wr); + ret = srq->device->post_srq_recv ? + srq->device->post_srq_recv(srq, wr, &bad_wr) : -EOPNOTSUPP; uobj_put_obj_read(srq); diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index b6ceb6fd6a67..9daae59572ac 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c @@ -479,6 +479,9 @@ static struct ib_ah *_rdma_create_ah(struct ib_pd *pd, { struct ib_ah *ah; + if (!pd->device->create_ah) + return ERR_PTR(-EOPNOTSUPP); + ah = pd->device->create_ah(pd, ah_attr, udata); if (!IS_ERR(ah)) {