Skip to content

Commit 00db63c

Browse files
paravmellanoxjgunthorpe
authored andcommitted
RDMA/cma: Check existence of netdevice during port validation
If valid netdevice is not found for RoCE, GID table should not be searched with NULL netdevice. Doing so causes the search routines to ignore the netdev argument and may match the wrong GID table entry if the netdev is deleted. Fixes: abae1b7 ("IB/cma: cma_validate_port should verify the port and netdevice") Signed-off-by: Parav Pandit <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 10bea9c commit 00db63c

File tree

1 file changed

+5
-3
lines changed
  • drivers/infiniband/core

1 file changed

+5
-3
lines changed

drivers/infiniband/core/cma.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,13 @@ static inline int cma_validate_port(struct ib_device *device, u8 port,
624624
if ((dev_type != ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port))
625625
return ret;
626626

627-
if (dev_type == ARPHRD_ETHER && rdma_protocol_roce(device, port))
627+
if (dev_type == ARPHRD_ETHER && rdma_protocol_roce(device, port)) {
628628
ndev = dev_get_by_index(&init_net, bound_if_index);
629-
else
629+
if (!ndev)
630+
return ret;
631+
} else {
630632
gid_type = IB_GID_TYPE_IB;
631-
633+
}
632634

633635
ret = ib_find_cached_gid_by_port(device, gid, gid_type, port,
634636
ndev, NULL);

0 commit comments

Comments
 (0)