Skip to content

Commit 3ff4de8

Browse files
avihai1122jgunthorpe
authored andcommitted
RDMA/core: Change rdma_get_gid_attr returned error code
Change the error code returned from rdma_get_gid_attr when the GID entry is invalid but the GID index is in the gid table size range to -ENODATA instead of -EINVAL. This change is done in order to provide a more accurate error reporting to be used by the new GID query API in user space. Nevertheless, -EINVAL is still returned from sysfs in the aforementioned case to maintain compatibility with user space that expects -EINVAL. Link: https://lore.kernel.org/r/20200923165015.2491894-2-leon@kernel.org Signed-off-by: Avihai Horon <avihaih@nvidia.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent a4947e8 commit 3ff4de8

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

drivers/infiniband/core/cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ EXPORT_SYMBOL(ib_get_cached_port_state);
12201220
const struct ib_gid_attr *
12211221
rdma_get_gid_attr(struct ib_device *device, u8 port_num, int index)
12221222
{
1223-
const struct ib_gid_attr *attr = ERR_PTR(-EINVAL);
1223+
const struct ib_gid_attr *attr = ERR_PTR(-ENODATA);
12241224
struct ib_gid_table *table;
12251225
unsigned long flags;
12261226

drivers/infiniband/core/sysfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,8 @@ static ssize_t _show_port_gid_attr(
387387

388388
gid_attr = rdma_get_gid_attr(p->ibdev, p->port_num, tab_attr->index);
389389
if (IS_ERR(gid_attr))
390-
return PTR_ERR(gid_attr);
390+
/* -EINVAL is returned for user space compatibility reasons. */
391+
return -EINVAL;
391392

392393
ret = print(gid_attr, buf);
393394
rdma_put_gid_attr(gid_attr);

0 commit comments

Comments
 (0)