Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3586388pxb; Mon, 24 Jan 2022 12:53:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIAvs8DS7Kknn3QUqfgVSAoFl069bFpdNL0mgqkk5KE1oXcPrvYsxJykZKJZTgkyEXraGg X-Received: by 2002:a17:90a:c287:: with SMTP id f7mr134003pjt.29.1643057613953; Mon, 24 Jan 2022 12:53:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643057613; cv=none; d=google.com; s=arc-20160816; b=xUCsvws5NOXLGUEcxf6q2ZYhnSWFe074rYm9VyOKfkDqTasc5vwFe/AbuLZtc9WwlY MGMqUTLSwlARRAIQZy7oJBAulYxB2zfiHza3HNVsempNmtD7aqMx/+tGHt63VLzOQYiS 3MqEFv1xmDJB3lEXDkXj+LgQf7YdIw8tcI5VX9re0zNESi7Df94RGLAK8qQM97cR0WcC dHpFQamI5xIq61eEjasm2uLI8PYwW5MR/GE5zHYOFnVa6UEqWbLsnbBSObg7O+mwPRQQ SeQzzmEzngrqsmESLGm8GwyYNi0nKFB1l6svx50UTCLhr0WxUebbqgdpXZuFM6ta1BNB BmxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iw4hXz4A/bNP/m/BGYanAyIcw2YmPJR1a6U664rdeCk=; b=v+ojrev+P7TRTo5MQjHyGR6sRs3dAw6Ji6D6i1xviBNpIF38rzxtLHa07iPp7lvoLs ezcr3zCAYG25Oudb721Wm0Oc39c8M4kYKOrHPKXg3vB7K0AEYsrn671Rzjq2a8VPoAX6 c1VsaN7qMEyyZAi/CaNGuuMVt964U/92TI+02X+j7Bmn4TRnfFaa9eeR4GZ13g1ZL3j/ EPoa63euXb3lIH7/AGaYGL6LcJRv/UBbdbHWmGwPFv9veDDLFvJsJbVzMqkyR672upDl MYtviOwlc28g0R46FvuXdfNp8Y3c79zWRIhZastLRRtEuFtN8BqIhG9cwT/gPUefCOuj bJKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DpKVVVd7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gp6si319075pjb.153.2022.01.24.12.53.21; Mon, 24 Jan 2022 12:53:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DpKVVVd7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348364AbiAXUNR (ORCPT + 99 others); Mon, 24 Jan 2022 15:13:17 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:51530 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358135AbiAXTyc (ORCPT ); Mon, 24 Jan 2022 14:54:32 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 31AD060B88; Mon, 24 Jan 2022 19:54:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F783C340E5; Mon, 24 Jan 2022 19:54:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643054068; bh=trFRVxPpwQP5j5PpHCK0jByQ6eNg8p9rOMd216bDq5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DpKVVVd7h48U6EEB02P20CG4+cFiLyz4IomYwKjGffx0UI8Zbz1JAIlgQIpVMFcAE Tkxbs3CKYMRoWNL76O9sCkgwrgxceYzg7feUebOOSG8H2+2kFOIhfp5HZAxEDA15t3 4VyfAmpMlN55OeugKEyyYA5oNgd06bebwsCGQskY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Avihai Horon , Mark Zhang , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.10 268/563] RDMA/core: Let ib_find_gid() continue search even after empty entry Date: Mon, 24 Jan 2022 19:40:33 +0100 Message-Id: <20220124184033.719964552@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184024.407936072@linuxfoundation.org> References: <20220124184024.407936072@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Avihai Horon [ Upstream commit 483d805191a23191f8294bbf9b4e94836f5d92e4 ] Currently, ib_find_gid() will stop searching after encountering the first empty GID table entry. This behavior is wrong since neither IB nor RoCE spec enforce tightly packed GID tables. For example, when a valid GID entry exists at index N, and if a GID entry is empty at index N-1, ib_find_gid() will fail to find the valid entry. Fix it by making ib_find_gid() continue searching even after encountering missing entries. Fixes: 5eb620c81ce3 ("IB/core: Add helpers for uncached GID and P_Key searches") Link: https://lore.kernel.org/r/e55d331b96cecfc2cf19803d16e7109ea966882d.1639055490.git.leonro@nvidia.com Signed-off-by: Avihai Horon Reviewed-by: Mark Zhang Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/core/device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 76b9c436edcd2..aa526c5ca0cf3 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -2411,7 +2411,8 @@ int ib_find_gid(struct ib_device *device, union ib_gid *gid, ++i) { ret = rdma_query_gid(device, port, i, &tmp_gid); if (ret) - return ret; + continue; + if (!memcmp(&tmp_gid, gid, sizeof *gid)) { *port_num = port; if (index) -- 2.34.1