Patch "RDMA/cma: Let cma_resolve_ib_dev() continue search even after empty entry" has been added to the 5.16-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    RDMA/cma: Let cma_resolve_ib_dev() continue search even after empty entry

to the 5.16-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     rdma-cma-let-cma_resolve_ib_dev-continue-search-even.patch
and it can be found in the queue-5.16 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 68302630b7442e7dfc4f595594789e057c7feefa
Author: Avihai Horon <avihaih@xxxxxxxxxx>
Date:   Thu Dec 9 15:16:07 2021 +0200

    RDMA/cma: Let cma_resolve_ib_dev() continue search even after empty entry
    
    [ Upstream commit 20679094a0161c94faf77e373fa3f7428a8e14bd ]
    
    Currently, when cma_resolve_ib_dev() searches for a matching GID it 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 the matching valid GID entry exists at index N, and if a
    GID entry is empty at index N-1, cma_resolve_ib_dev() will fail to find
    the matching valid entry.
    
    Fix it by making cma_resolve_ib_dev() continue searching even after
    encountering missing entries.
    
    Fixes: f17df3b0dede ("RDMA/cma: Add support for AF_IB to rdma_resolve_addr()")
    Link: https://lore.kernel.org/r/b7346307e3bb396c43d67d924348c6c496493991.1639055490.git.leonro@xxxxxxxxxx
    Signed-off-by: Avihai Horon <avihaih@xxxxxxxxxx>
    Reviewed-by: Mark Zhang <markzhang@xxxxxxxxxx>
    Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
    Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 835ac54d4a24c..a3834ef691910 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -766,6 +766,7 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
 	unsigned int p;
 	u16 pkey, index;
 	enum ib_port_state port_state;
+	int ret;
 	int i;
 
 	cma_dev = NULL;
@@ -784,9 +785,14 @@ static int cma_resolve_ib_dev(struct rdma_id_private *id_priv)
 
 			if (ib_get_cached_port_state(cur_dev->device, p, &port_state))
 				continue;
-			for (i = 0; !rdma_query_gid(cur_dev->device,
-						    p, i, &gid);
-			     i++) {
+
+			for (i = 0; i < cur_dev->device->port_data[p].immutable.gid_tbl_len;
+			     ++i) {
+				ret = rdma_query_gid(cur_dev->device, p, i,
+						     &gid);
+				if (ret)
+					continue;
+
 				if (!memcmp(&gid, dgid, sizeof(gid))) {
 					cma_dev = cur_dev;
 					sgid = gid;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux