From patchwork Sat Jul 14 23:28:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Heib X-Patchwork-Id: 10524921 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 A7F4D6028E for ; Sat, 14 Jul 2018 23:28:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9939E28956 for ; Sat, 14 Jul 2018 23:28:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E2AA28977; Sat, 14 Jul 2018 23:28:27 +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 303C928A1D for ; Sat, 14 Jul 2018 23:28:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731483AbeGNXtJ (ORCPT ); Sat, 14 Jul 2018 19:49:09 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34027 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731555AbeGNXtJ (ORCPT ); Sat, 14 Jul 2018 19:49:09 -0400 Received: by mail-wr1-f68.google.com with SMTP id c13-v6so28347898wrt.1 for ; Sat, 14 Jul 2018 16:28:25 -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=tFyIAhod5xnD5wH0GXCWQMdURveFOhjQTVBXQdcfHyE=; b=X9gQbiaJnXnqJi6EL5XqqRD/6MggVsbc4LHk5NFZKtrVzX2iT0VqVXzYOHB90ItkwA yD6ShH4FPKy07fAWWAgjiUgcfTIoH06PEbNUFaKbVZuQJaRpL+QHMrdcVxvvMTOw2+sV cNhCAJyB+ymh5S9dva+alzoyjWuwAXXIbR8r0SGjmYajgTqxsvxbpBSeZWOIFQO0nTFy /tQt8Yq+qsxMD4Tn/TQlNUGzpSYtyY8Fh/Nm1GOMLnQhlnbZchAnputOF/OMliNtQygh EzlFgl3Z0k8XPkiv3VH/NDGjIrPzdLDFbj2AY5vhIbsipDixSKIR9WCryJy0EEv5FAx9 3zpw== 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=tFyIAhod5xnD5wH0GXCWQMdURveFOhjQTVBXQdcfHyE=; b=pt6gnq9KvhJKqfbnh3mgdIwx+lCZrrg7S1WPLLsiVYaFTTlrr0bSCoqnOEYypoUZMf m0v+prSITnB05oemlxr9p2xJbOWNglVsjnqfd2qsrY6kB8xVIaMYAJDp9bnFahfzOZVh 77Vw7zF5HdgP+MD6mlO3ZmN4vBjRZFcG3tUetZ5NxE180KFWq3poE4pMA0Y2F1N2Jk2f gGnbt0cA8VKX+nI9Va7lbZTSUmup9Q8JPCFzGAlU6s1SuHZLAQ0WSXJnHXvrEuxKcBgT 9I/0DZgEbOk+KHrahSg+JMYOa9NbenU7Se48L9ts5b9XwyH5aD/Tm4LuHIRQk31p5stT 3MEw== X-Gm-Message-State: AOUpUlFMg6PTcRsGqdmrfs9zyQC61hKxENIv9xInkQ1yL9yyLW/P7ipR RUPCBxlPeLfv7o9Kj89STRY= X-Google-Smtp-Source: AAOMgperAnY37WlK/NknPI+g3KXnrdOxSQJoCtWBZJ9vw8+ZIJ8DRg5WVzSDBjxXQ65BkQB0mF8jag== X-Received: by 2002:adf:dbc3:: with SMTP id e3-v6mr8158865wrj.217.1531610904712; Sat, 14 Jul 2018 16:28:24 -0700 (PDT) Received: from localhost.localdomain (bzq-109-67-23-64.red.bezeqint.net. [109.67.23.64]) by smtp.gmail.com with ESMTPSA id y14-v6sm19299795wrq.45.2018.07.14.16.28.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 14 Jul 2018 16:28:24 -0700 (PDT) From: Kamal Heib To: Doug Ledford , Jason Gunthorpe Cc: linux-rdma@vger.kernel.org, Kamal Heib Subject: [PATCH rdma-next v2 2/3] RDMA/core: Check for verbs callbacks before using them Date: Sun, 15 Jul 2018 02:28:10 +0300 Message-Id: <20180714232811.9164-3-kamalheib1@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180714232811.9164-1-kamalheib1@gmail.com> References: <20180714232811.9164-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 bd6eefaecbd6..6ab00f322b62 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)) {