Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3975994pxb; Tue, 25 Jan 2022 00:26:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJyogW5QknsFoubhrlU2woopqXzdSuwHMwZ7YrqmduzmSckqFv1tba0jJ3hH520BRx7gsV45 X-Received: by 2002:a17:903:41c9:b0:14b:53f9:b4fa with SMTP id u9-20020a17090341c900b0014b53f9b4famr7435832ple.166.1643099178178; Tue, 25 Jan 2022 00:26:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643099178; cv=none; d=google.com; s=arc-20160816; b=kGUJwW1lVOUaZ1gI4N2Yls1QK47jSIWofSTsfDaZqSPYnECa5jYD8mtuv65MRRYaPT rqYYX17IPMCjlxgaJXnFvX/0dwrSLjUDwDa4EyYEgM/p62kYzjaty+T2QSDa4DC001YF L4J26qT0khxe5vtRYdZmoNQZ5JtHSm08S7W1nxEIVRExVgfhcQS7Yw+RExrxGasO921v S8Las9fDyJzseNE1ZWB3XOIlP4eWNgqj2iXtRTDuj2qAf73KQGkJmX2VHlBdiJmNJ7HM hH35/W2MFwqkRXViopVgJgBGKa5sPp4AXIGa8nmgvhcr6nl6Voc3bCyKOwpeqAXW/UPO BH/A== 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=hjSIDOCmLSayWiQPYRsT0ZoWm0UdxyKrk+TO+ViBPuY=; b=WMZJnK3YtiMC+eOFS5W0ooeTbI3Su754iqiP8soRWWPJ1amduJIDrqlb6pmV7S8s7E LUPrR3hHdkw/v8ijRzD0ltypzjueN5Y9veL6Y9qmVDgqxrYfy0Jw+BDUZx7sLJGXbdKm 2JAZb3bTneoSmLEdVsx4KyasHp2/NOZPABHtvpnjjTwQ4rYIUmEHY4almWw/wqwdvyXl MO+ek8ljbhbtoZMqLKAM16IUSdidVGpZbLpqfNYhSn76CbpMvrsJ0JJSFtgrsR4IDQD/ PjixqsDaWLlzCfRkMrFF8u6Ejy2wguDOa1xBC2NGnJh23YWQAZe0JfurPbZVljLt2rx5 V+Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iy7vgXPY; 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 z3si14187035plg.406.2022.01.25.00.26.06; Tue, 25 Jan 2022 00:26: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=iy7vgXPY; 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 S3422005AbiAYC3p (ORCPT + 99 others); Mon, 24 Jan 2022 21:29:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357849AbiAXUJe (ORCPT ); Mon, 24 Jan 2022 15:09:34 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E07DC02983A; Mon, 24 Jan 2022 11:33: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 ams.source.kernel.org (Postfix) with ESMTPS id 4551BB8121C; Mon, 24 Jan 2022 19:33:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 689D5C340E5; Mon, 24 Jan 2022 19:32:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052779; bh=MGcczI86XdxpzZ8+PoJv+QLLEjPqQxli/cTut4UHhGo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iy7vgXPYC95Rasyu3ywwZmVNLyoXqVnb5F4ExwHjoIeYskg7+72VKwFbjof8Cclnj 2FdOjnPzR7I9FvtFbolvXZhiytfYOmbz46+7s7ZXFAtIdIe5nLXElWkyrMAakt4HZF VsfRtLyNFpKTNoQKTow+j/b8OzIkque9DkMI+FKw= 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.4 138/320] RDMA/core: Let ib_find_gid() continue search even after empty entry Date: Mon, 24 Jan 2022 19:42:02 +0100 Message-Id: <20220124183958.348215298@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@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 256d379bba676..de66d7da1bf6e 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -2438,7 +2438,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