From patchwork Sun Feb 14 15:07:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 8302201 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D48219F7BC for ; Sun, 14 Feb 2016 15:08:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EA691203E3 for ; Sun, 14 Feb 2016 15:08:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0CCBF2039E for ; Sun, 14 Feb 2016 15:08:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751440AbcBNPI1 (ORCPT ); Sun, 14 Feb 2016 10:08:27 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35904 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751402AbcBNPIN (ORCPT ); Sun, 14 Feb 2016 10:08:13 -0500 Received: by mail-wm0-f66.google.com with SMTP id a4so6455965wme.3 for ; Sun, 14 Feb 2016 07:08:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leon-nu.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=I5lK7Ss4E0HId86KvNi/73o1mnqXTw7LjskbUlhUojg=; b=gRSUTrFvtAPxgQOd7NFCjGZhpV+XVYgmnfNZYbW5wEQ+ToN+36epr2DA+wnQWmoO5+ ddjiZ/6Bl0t/FYv6PGK2Enk/Se1kUVFZqXYKwcRC5C0Q7m6c2yLmu1J1R9+UCX1Ez0gS t/wylqvWAR0oYidOjgVsvOwbqFxw9rA3Znx2PJTJ3StrBg/ABjwBK8CoHl3zq49uC4ac A+WmpCcXebZvMI0hwPZ3nqJFVAJ4l1jmea653y7IewM1/b4sbnxpQowAJyPBkxBaDtiB OXd+/FB6iZ1zJgVnoS7WV3v1w5FswqfMOOt5lOAghy6BL07iZp0klIBsmx6MUCXYTmy4 lKnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=I5lK7Ss4E0HId86KvNi/73o1mnqXTw7LjskbUlhUojg=; b=ANzV+QZrXJH24l1AEME/pD667mEQDcglIlEQJFOo1m0FcipQ/w2EYkSxLmCXDJNwbK mYXPb4aoI6/uUQZqs4+zdwhvK9At/RMYBEob/5h6WQlGrD7jAIQAg32DxhfDr15hTeOH tOXGq8qhtWkbyeL7tsLnWusa6Fri/ozmL5zqYM+F3yQYXGHzYNK2T50Y/7D5+2brivhD MaXyC98NOWF9NNQfGB9XYiObGy09l8BbQ5sIdmuW2nFE+XVNzAa0zqe7ADYrJJg8uWLU MPTk4AAoEs7be9ZXSqB09higlTSe5JLPAWWL3/yucdNactOKsMSNar+EZWaV4sJb0rEg mkzg== X-Gm-Message-State: AG10YOQcCxZAbed1os98CiVAVhBXCvTGv9FCHnXX6NyCZEWyFoq2RsUtsYiNHyCafGtROw== X-Received: by 10.194.57.48 with SMTP id f16mr10763628wjq.99.1455462492180; Sun, 14 Feb 2016 07:08:12 -0800 (PST) Received: from localhost ([213.57.247.249]) by smtp.gmail.com with ESMTPSA id et11sm21019156wjc.30.2016.02.14.07.08.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Feb 2016 07:08:11 -0800 (PST) From: Leon Romanovsky To: dledford@redhat.com Cc: linux-rdma@vger.kernel.org, Eli Cohen , Leon Romanovsky Subject: [PATCH rdma-next 3/3] IB/core: Modify conditional on ucontext existence Date: Sun, 14 Feb 2016 17:07:49 +0200 Message-Id: <1455462469-9124-4-git-send-email-leon@leon.nu> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455462469-9124-1-git-send-email-leon@leon.nu> References: <1455462469-9124-1-git-send-email-leon@leon.nu> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eli Cohen Since we allow to call legacy verbs using their extended counterpart, the check on ucontext has to move up to a common area in case this verb is ever extended. Signed-off-by: Eli Cohen Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/uverbs_main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index 20f0049..8b299df 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -735,6 +735,12 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, goto out; } + if (!file->ucontext && + command != IB_USER_VERBS_CMD_GET_CONTEXT) { + ret = -EINVAL; + goto out; + } + flags = (hdr.command & IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT; @@ -745,12 +751,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, goto out; } - if (!file->ucontext && - command != IB_USER_VERBS_CMD_GET_CONTEXT) { - ret = -EINVAL; - goto out; - } - if (hdr.in_words * 4 != count) { ret = -EINVAL; goto out;