Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3973941pxb; Tue, 25 Jan 2022 00:22:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJziv6CzACW4gxcVfFuH6S0i1AFrav3xJVZ/HoTstyoeL/QUd8PXMO5n6qA3/EaL9J4EIuCQ X-Received: by 2002:a17:906:1d58:: with SMTP id o24mr15614478ejh.277.1643098943860; Tue, 25 Jan 2022 00:22:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643098943; cv=none; d=google.com; s=arc-20160816; b=CLgSAyIqfc/Yvl8A3jqobLKCYCDPmilOPj+b+BjNkUDxAgNwMCU4NrAh3EcK4Q+IY5 HndcvHbjoajOl+lnIW7KafZgOypdOwZ8AJboJOAUY9rM0QDfCUlmt+t51og1wnoym0mF fSOELJYZUpgfSNy35SywiHyX69U7lzwx2oo1UrsU8IOfYktsxW4cekeYTL3sIbNy8g+Q edt6VuyevAy0UyS82+Zw+HJgP0prjSOn6iBiUg9p7U25K+o2MCS1qKJ1nQE86xGSN9qp Dxeu7P1WeNdV60SV5MSdPbWBF0wjr/2wi2hhUKQoVz7k1S/IRhNuJbINGqlMX+Iei0wF i+XA== 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=5ls8whPkDzOT4PDNz9+kWyFblNlUyHBkWvakG3+J8fE=; b=fAVxkMa8XfHn0Oy9ueRzgh74HLfTHpeAij9PEcJixcsqr4IDi8BCq3gWXr6GDriHOF LNSXujJyS1cNe9ANQZUfpYskOM4m8IsUYsdykWLDXNKpWngiWguZcRkXHW+ykq5Mt9KS 00nMHt60cBtUBxvgjSJmSl/ED0P2giAuEr4mQH7StJmDGlEk1aD5+ZARjqAiuWwc1N9B hEbfhltOS3vgyuYvNp0eR7FSNaDSp6qp6nZpVIZVNFHfYShbJ/bBSVbT1G1+lyq1rGv8 +1XBJXOvnu3UJrotl1arkVLp9h4/997FLZEOvicZxIZKon+QrsCR8z+gc/VZkvsvjWYs Pf3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tgPbZmAy; 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 30si9153487ejq.841.2022.01.25.00.21.59; Tue, 25 Jan 2022 00:22:23 -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=tgPbZmAy; 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 S3420772AbiAYCZV (ORCPT + 99 others); Mon, 24 Jan 2022 21:25:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349606AbiAXTVC (ORCPT ); Mon, 24 Jan 2022 14:21:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13745C02B8FE; Mon, 24 Jan 2022 11:08:01 -0800 (PST) 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 A555660915; Mon, 24 Jan 2022 19:08:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F630C340EA; Mon, 24 Jan 2022 19:07:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051280; bh=FM2bYuIVU7i8XDbf8yK2c65qTaw8aLmdf2NX831CQgY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tgPbZmAywowvJT8X+g281zKUgDz5pTfEPCUenBALpODzUrXu2s3QnKyOSnoGijYoE 7ptUp4vMs68Ym9ivOZtyGTlwOH1wmh+IpT1jza3p3t9yq6Qtu6MUq6n5ZAL2zxddCB /AD8j12UhaWCG7Q80IcOMYT3baa02B5T393WIK9g= 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 4.14 078/186] RDMA/core: Let ib_find_gid() continue search even after empty entry Date: Mon, 24 Jan 2022 19:42:33 +0100 Message-Id: <20220124183939.635276845@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@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 6b0d1d8609cad..b230f156a9964 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -1075,7 +1075,8 @@ int ib_find_gid(struct ib_device *device, union ib_gid *gid, for (i = 0; i < device->port_immutable[port].gid_tbl_len; ++i) { ret = ib_query_gid(device, port, i, &tmp_gid, NULL); if (ret) - return ret; + continue; + if (!memcmp(&tmp_gid, gid, sizeof *gid)) { *port_num = port; if (index) -- 2.34.1