Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3705902pxb; Mon, 24 Jan 2022 15:54:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJcT9dZFwX9J4nT30zmXDnLaOUPJCD/HMYSI7hCnQ5nUu0zLoz86D39J42kSeFGBzP+akY X-Received: by 2002:a17:902:7889:b0:14b:6182:a263 with SMTP id q9-20020a170902788900b0014b6182a263mr3763090pll.15.1643068498016; Mon, 24 Jan 2022 15:54:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643068498; cv=none; d=google.com; s=arc-20160816; b=LGHE37BIowhljL5IeOe+rgxsgXaNKJUtHUzky9Iynam53CoP9tHoWckz9TYiVXBo4e RevxKSKbR2f/RLLTxrihy56saOcL/vXjTWlrElMqE99WaQxzhOD9uWJ/ijhjBrmXGY2U 6zcDGfcSzTzdngTvhBPToq+VeLgcrEsqKHUOIj6VVJIYMBv7HJGxGz58Y+xBtwysb+aO bkDhVBAn/woUqP8lW58SvBq2CZQaWgOhECNGin2vhkFRmGl5Z11r9H/Ya5wUK4cpkWWB WFcCMO28saMZ+X4H3Nag/g59DjogcDKpEdq1ONGStOmuW3U5sywxRVrZ1ZfTCgLUOzDP lISA== 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=Q353nLTmiZHgnp87n+vFTo2F/7CjF2w+8UISw1SNuvQ=; b=V/Btv/PAGnU2JdHfINGkjKkYf/U+dTewJTWSSjcCt5eqCLen51NFgkXpjg46SnMD/T BXa9dLRMUFnvOEFSKDmzeKKFUs3NPt4mq/dWrUt0RSBC6wslKqEWWRZT9/MLCuQsGR1u TWXP+YfWBar6kPl7sYOabtqau3ATzwQpxPJ3jNHnoLO+g/w2O0vOhVsMm6i+iCnbGSdk YeQ7YO21eO39J/OYBcxGFxVQVqZByLzPolYSxv9lfi00MLkbRJGJi2mT+IKJm1NCyuoh BwVu9W8FAU2gjGZq8IDfskJCmOw9/lPHvmmyOWVAQWGijvBdHL8ofx0zJGzmb34+XMZu rfxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0fY1sI4U; 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 138si15055311pgc.498.2022.01.24.15.54.45; Mon, 24 Jan 2022 15:54:58 -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=0fY1sI4U; 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 S2365576AbiAXXvS (ORCPT + 99 others); Mon, 24 Jan 2022 18:51:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1843807AbiAXXGY (ORCPT ); Mon, 24 Jan 2022 18:06:24 -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 2C4BCC06E038; Mon, 24 Jan 2022 13:17:17 -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 C07DA614F5; Mon, 24 Jan 2022 21:17:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9BC7C340E4; Mon, 24 Jan 2022 21:17:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059036; bh=GSpa0T2zR5nR7t2XEWNXHM0JnhWayGNeHrauchlvb2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0fY1sI4UlPS5//AukobzXcdfyx3DdCbsi4m6B3yIZ6gQaU30UC/luJVJPnlbIiiEt 4V4mBner5AZbfTudAhRuLKD5Ud6pKATC3C4WccpWGka34nD5dTTnhrFmdITgO+HvCK NawdW0D2zvZLajQIGqn24uHYNUpIVHDUlYMhb888= 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.16 0484/1039] RDMA/core: Let ib_find_gid() continue search even after empty entry Date: Mon, 24 Jan 2022 19:37:53 +0100 Message-Id: <20220124184141.543595123@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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 22a4adda7981d..a311df07b1bdb 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -2461,7 +2461,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