Skip to content

Commit b4a797b

Browse files
Junxian Huangrleon
authored andcommitted
RDMA/hns: Fix unnecessary port_num transition in HW stats allocation
The num_ports capability of devices should be compared with the number of port(i.e. the input param "port_num") but not the port index(i.e. port_num - 1). Fixes: 5a87279 ("RDMA/hns: Support hns HW stats") Signed-off-by: Junxian Huang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 27c5fd2 commit b4a797b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/infiniband/hw/hns/hns_roce_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,9 +547,8 @@ static struct rdma_hw_stats *hns_roce_alloc_hw_port_stats(
547547
struct ib_device *device, u32 port_num)
548548
{
549549
struct hns_roce_dev *hr_dev = to_hr_dev(device);
550-
u32 port = port_num - 1;
551550

552-
if (port > hr_dev->caps.num_ports) {
551+
if (port_num > hr_dev->caps.num_ports) {
553552
ibdev_err(device, "invalid port num.\n");
554553
return NULL;
555554
}

0 commit comments

Comments
 (0)