From patchwork Tue Sep 15 14:13:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "gregkh@linuxfoundation.org" X-Patchwork-Id: 309739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E5B9C43461 for ; Tue, 15 Sep 2020 14:31:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D2AC22265 for ; Tue, 15 Sep 2020 14:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600180302; bh=+/4Gi/warB2s9shqbQ2i8K/l2a79KsNB7gX8hhBj9Xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=tZs5yBWcIkZQFmHJuOSel8HiQzZAulLUCbbBR9Iex03FcbUKtD5q+0BXu/cnnXLim 3adTcc8crRK522Lt4f1D152ypRj/D+wwSCZVWuG5aXoU/8pXh2CndFVx45hmegAYce P9B6H1DZzwA5YtKxmPMzTZwRdMoVlgriqq1mk8Sk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727068AbgIOObk (ORCPT ); Tue, 15 Sep 2020 10:31:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:44122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727036AbgIOOba (ORCPT ); Tue, 15 Sep 2020 10:31:30 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3A60822B48; Tue, 15 Sep 2020 14:22:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179770; bh=+/4Gi/warB2s9shqbQ2i8K/l2a79KsNB7gX8hhBj9Xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HQ1fc8kuy6FsTAWS9mL5J1FIvsB0gdq9LukXB6VlR1KRL1WT0UGW1KAN046R5JjhN jn/ydk25hQgjs2HMc07/+vUptg8tlNz/Gahz4M34s+qx3u2GBxCq+jV0nHJMjz5kcN rahUcVh6VVugkrgmz+EOLcxTdgfjzPnqwcFRlLQ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Bloch , Maor Gottlieb , Leon Romanovsky , Jason Gunthorpe Subject: [PATCH 5.4 111/132] RDMA/mlx4: Read pkey table length instead of hardcoded value Date: Tue, 15 Sep 2020 16:13:33 +0200 Message-Id: <20200915140649.682609222@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140644.037604909@linuxfoundation.org> References: <20200915140644.037604909@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mark Bloch commit ec78b3bd66bc9a015505df0ef0eb153d9e64b03b upstream. If the pkey_table is not available (which is the case when RoCE is not supported), the cited commit caused a regression where mlx4_devices without RoCE are not created. Fix this by returning a pkey table length of zero in procedure eth_link_query_port() if the pkey-table length reported by the device is zero. Link: https://lore.kernel.org/r/20200824110229.1094376-1-leon@kernel.org Cc: Fixes: 1901b91f9982 ("IB/core: Fix potential NULL pointer dereference in pkey cache") Fixes: fa417f7b520e ("IB/mlx4: Add support for IBoE") Signed-off-by: Mark Bloch Reviewed-by: Maor Gottlieb Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/mlx4/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -781,7 +781,8 @@ static int eth_link_query_port(struct ib props->ip_gids = true; props->gid_tbl_len = mdev->dev->caps.gid_table_len[port]; props->max_msg_sz = mdev->dev->caps.max_msg_sz; - props->pkey_tbl_len = 1; + if (mdev->dev->caps.pkey_table_len[port]) + props->pkey_tbl_len = 1; props->max_mtu = IB_MTU_4096; props->max_vl_num = 2; props->state = IB_PORT_DOWN;