Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753008AbdGMTht (ORCPT ); Thu, 13 Jul 2017 15:37:49 -0400 Received: from mga05.intel.com ([192.55.52.43]:27946 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752587AbdGMThq (ORCPT ); Thu, 13 Jul 2017 15:37:46 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,355,1496127600"; d="scan'208";a="111046364" From: Mustafa Ismail To: linux-rdma@vger.kernel.org Cc: dledford@redhat.com, swise@opengridcomputing.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org, gregkh@linuxfoundation.org, shiraz.saleem@intel.com Subject: [PATCH 1/2] RDMA/uverbs: Fix the check for port number Date: Thu, 13 Jul 2017 14:37:37 -0500 Message-Id: <1499974658-6180-2-git-send-email-mustafa.ismail@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499974658-6180-1-git-send-email-mustafa.ismail@intel.com> References: <1499974658-6180-1-git-send-email-mustafa.ismail@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 910 Lines: 26 The port number is only valid if IB_QP_PORT is set in the mask. So only check port number if it is valid to prevent modify_qp from failing due to an invalid port number. Fixes: 5ecce4c9b17b("Check port number supplied by user verbs cmds") Signed-off-by: Mustafa Ismail --- 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 8ba9bfb..19de068 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c @@ -1935,7 +1935,8 @@ static int modify_qp(struct ib_uverbs_file *file, goto out; } - if (!rdma_is_port_valid(qp->device, cmd->base.port_num)) { + if ((cmd->base.attr_mask & IB_QP_PORT) && + !rdma_is_port_valid(qp->device, cmd->base.port_num)) { ret = -EINVAL; goto release_qp; } -- 2.7.4