Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/core: Modify rdma_query_gid() to return accurate error codes

Modify rdma_query_gid() to return -ENOENT for empty entries. This will
make error reporting more accurate and will be used in next patches.

Link: https://lore.kernel.org/r/1f2b65dfb4d995e74b621e3e21e7c7445d187956.1639055490.git.leonro@nvidia.com
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Mark Zhang <markzhang@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Avihai Horon and committed by
Jason Gunthorpe
109f2d39 0045e0d3

+9 -3
+9 -3
drivers/infiniband/core/cache.c
··· 955 955 { 956 956 struct ib_gid_table *table; 957 957 unsigned long flags; 958 - int res = -EINVAL; 958 + int res; 959 959 960 960 if (!rdma_is_port_valid(device, port_num)) 961 961 return -EINVAL; ··· 963 963 table = rdma_gid_table(device, port_num); 964 964 read_lock_irqsave(&table->rwlock, flags); 965 965 966 - if (index < 0 || index >= table->sz || 967 - !is_gid_entry_valid(table->data_vec[index])) 966 + if (index < 0 || index >= table->sz) { 967 + res = -EINVAL; 968 968 goto done; 969 + } 970 + 971 + if (!is_gid_entry_valid(table->data_vec[index])) { 972 + res = -ENOENT; 973 + goto done; 974 + } 969 975 970 976 memcpy(gid, &table->data_vec[index]->attr.gid, sizeof(*gid)); 971 977 res = 0;