From patchwork Fri Jul 27 18:23:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Heib X-Patchwork-Id: 10547567 X-Patchwork-Delegate: jgg@ziepe.ca 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 2509E112E for ; Fri, 27 Jul 2018 18:23:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FC2C2C0AD for ; Fri, 27 Jul 2018 18:23:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1450A2C305; Fri, 27 Jul 2018 18:23:21 +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 B83EE2C0AD for ; Fri, 27 Jul 2018 18:23:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388909AbeG0TqX (ORCPT ); Fri, 27 Jul 2018 15:46:23 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:55796 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388857AbeG0TqX (ORCPT ); Fri, 27 Jul 2018 15:46:23 -0400 Received: by mail-wm0-f65.google.com with SMTP id f21-v6so6164354wmc.5 for ; Fri, 27 Jul 2018 11:23:18 -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=ZLDgw6FnFe4zU8mJvEtQp6QeEfOapsYofxg61mCtADc=; b=VczpU/+9SAf5CG1fagogrjzf1XfRlxW/Gd/Vu3wY0zIpcR1HuA2Hms5uTzCaacxzFi HjLcHT1g7ZcrsNTdBZclV/z/2NhO9S/zli94O9bVy2dtR2el9oryzKKX2hDZiw23HWsM 8o+SMUGnrkghEwMKUdufAxCV3K/MIl+2yDIGUhZh+biD/Zira3+DaFqCsZEg6Q5O/kQo 863uu3u3crNglyldSBJoyDW9AtG3LRagGd3aHxpBhRscPy+Cb48l5qfRqHYkXXYaQnnr uK9axwp1jUtzUag1VQi3w4ZFs1lRCR/f5+kkl6qoHy+aaT2oxCGARI20De/cIbV1iIFE dsKw== 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=ZLDgw6FnFe4zU8mJvEtQp6QeEfOapsYofxg61mCtADc=; b=eUjZ8blOa5Jmke8iuum8f7JUYgiIXKGQzzw5TBU+LKCKjttEOkXXkBvLtu8Au+tD9L U/7zx/JwSHOp6snKybvChXmXjkJnqXRTTYzCMMOczr3ljwSD5ax5Gzig9xmkrbV9553X 74BI0RfM4ktKS9BYgE4peGrduTJSxPHq4qBGGQocTN1Q91bPC0xgKrIDxR/T8EognASD Xg87fGGim7F1HmTDF5+e0baNLTjFreKLtkELo0vghAnBruy251hd7e70cPq8/NiTyVTs tD2L0qiqVs3uEztcn/+YabTZYQkWw5gb7TrU+dn5EIVBlPxJK7vEgsPogr/osPKwXHBX PI5A== X-Gm-Message-State: AOUpUlGLNDfCORCo6EgDyps/+5cYj88K83GzdCv34M/0RyKTvVgzbl5F aEVEjxzzS6C7YNdQfbkSgT949/7l X-Google-Smtp-Source: AAOMgpcsmaQDBfSKyCENfsI6RW6v6pkxPsHG24RBursRF44XgDMVTRmGcYXJRdW7NNUL0XxdmHMdTw== X-Received: by 2002:a1c:f001:: with SMTP id a1-v6mr5522550wmb.160.1532715797648; Fri, 27 Jul 2018 11:23:17 -0700 (PDT) Received: from localhost.localdomain ([2.53.146.104]) by smtp.gmail.com with ESMTPSA id u18-v6sm9192340wrm.80.2018.07.27.11.23.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 27 Jul 2018 11:23:17 -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 v4 2/3] RDMA/core: Check for verbs callbacks before using them Date: Fri, 27 Jul 2018 21:23:05 +0300 Message-Id: <20180727182306.26664-3-kamalheib1@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180727182306.26664-1-kamalheib1@gmail.com> References: <20180727182306.26664-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 38d7de3f9b2f..a2cfa7908d7e 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -2501,7 +2501,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 cde359d48d34..5b76c7ebfa02 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)) {