Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3555322pxb; Mon, 24 Jan 2022 12:07:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJy1SZ31v7nhQsD7r925boc25woKNhTAhAJXLZNRzQtY9QGKQtfSB0sG+Sx75IKhS7C14gt6 X-Received: by 2002:a17:90b:3b48:: with SMTP id ot8mr3467827pjb.95.1643054838212; Mon, 24 Jan 2022 12:07:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054838; cv=none; d=google.com; s=arc-20160816; b=pTyj4pg5WF+qz9MIhbVgf3Ijs/KE1YkigdmtEgW82oFnW9Zz1+YbEjTWisJemKE7B1 aozW9AcUpE/k6IIDagNdpacg9FTPuSRdVqPMN9jmrb6DnZP1C8ge/Rd7JbswRm88foJf zCPkVFz10iiStImUdREpnpjaXexwNWdH85+iv3a/+vEP5JzUtqNhQpFHasnfD6A4pPI8 C4/6JPnS2Y7crcL4nHv5A2aZRxOb4Mow2+ePreovGInCr5okQOrSvnV3BrKheHRJFaI0 JYF+PN7q2N9dvmUepTrq2tEqal67tD65byCH4L4hJnpB0WB2j6zV1NyzBbYvFepKyagR IRUA== 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=/z+rSF7hqwa+K6fwtM+viiT6Tcu5T4etMXvL8IGA1Vs=; b=SyitUKhGmLwG3m3BDNSe+7JjqlHMJMROjZLNAHT85y6T95ilf+SELpYpJXzIcenzib OQufmh4hPyks0GNj9HNvN6SzBuQLrECvSNm6wIoDvcd+uRtdlX6FqjfkFiUB+P8VStdJ JUcWVWMeZlZbZbyzLuq+ELMOQ0YZeGoGdcrLChyVOhRC4/yugpGsTzpkq2HwEtM50auQ tt79hWGMrXHo7nxG3dUfrFRkuTFS7nT+nx2m6gQHd5VO9Tkb5CNhBAeF9EmzlsHzXlWS HWglfB3WdjQPXawDVjb+4D2fd6l1mk9Q4FGSmBqj1G0lvSOXxMZRVaSkOfBXIlzvvYl9 WPJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xHkQZD1K; 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 j12si14748510pfu.247.2022.01.24.12.07.05; Mon, 24 Jan 2022 12:07:18 -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=xHkQZD1K; 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 S1345910AbiAXTEo (ORCPT + 99 others); Mon, 24 Jan 2022 14:04:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345351AbiAXTAI (ORCPT ); Mon, 24 Jan 2022 14:00:08 -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 8C1D4C06179A; Mon, 24 Jan 2022 10:57:22 -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 294CE6153A; Mon, 24 Jan 2022 18:57:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCF7DC340E5; Mon, 24 Jan 2022 18:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050641; bh=w46WblcSNnkv/REghqn6QUVMuYOSbyXJbKRtxqJJU4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xHkQZD1KhE3lYh+d2w/ePp3bMpAmer4UU8vyjm3VlY1tGbX1ioSGm6+NnCVpSquMp Ic5nxskLJ8hHCFYyJsvvONhuw/kQ4fktxmziXuZP9iAL9p8/jnlo2whkJN7vR0mMBq yCUD4MRsURCHLCdq+alqtAXqOGbbBnYHXzCkp8X4= 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.9 066/157] RDMA/core: Let ib_find_gid() continue search even after empty entry Date: Mon, 24 Jan 2022 19:42:36 +0100 Message-Id: <20220124183934.877562935@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183932.787526760@linuxfoundation.org> References: <20220124183932.787526760@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 4b947d5cafe28..c5c175b72f21e 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -870,7 +870,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