Message ID | 022047a8b16988fc88d4426da50bf60a4833311b.1719235449.git.leon@kernel.org (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [rdma-next] RDMA/device: Return error earlier if port in not valid | expand |
On Mon, 24 Jun 2024 16:24:32 +0300, Leon Romanovsky wrote: > There is no need to allocate port data if port provided is not valid. > > Applied, thanks! [1/1] RDMA/device: Return error earlier if port in not valid https://git.kernel.org/rdma/rdma/c/917918f57a7b13 Best regards,
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 8547cab50b23..7aaf2b4c1844 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -2163,6 +2163,9 @@ int ib_device_set_netdev(struct ib_device *ib_dev, struct net_device *ndev, unsigned long flags; int ret; + if (!rdma_is_port_valid(ib_dev, port)) + return -EINVAL; + /* * Drivers wish to call this before ib_register_driver, so we have to * setup the port data early. @@ -2171,9 +2174,6 @@ int ib_device_set_netdev(struct ib_device *ib_dev, struct net_device *ndev, if (ret) return ret; - if (!rdma_is_port_valid(ib_dev, port)) - return -EINVAL; - pdata = &ib_dev->port_data[port]; spin_lock_irqsave(&pdata->netdev_lock, flags); old_ndev = rcu_dereference_protected(