[PATCH rdma-next 4/7] RDMA/device: Clear netdev mapping in ib_device_get_netdev on unregistration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Maher Sanalla <msanalla@xxxxxxxxxx>

The caller of ib_device_get_netdev() relies on its result to accurately
match a given netdev with the ib device associated netdev.

ib_device_get_netdev returns NULL when the IB device associated netdev
is unregistering, preventing the caller of matching netdevs properly.

Thus, revise ib_device_get_netdev to assign NULL to netdev when the netdev
is undergoing unregistration, allowing matching by the caller.

This change ensures proper netdev matching and reference count handling
by the caller of ib_device_get_netdev/ib_device_set_netdev API.

Fixes: c2261dd76b54 ("RDMA/device: Add ib_device_set_netdev() as an alternative to get_netdev"
Signed-off-by: Maher Sanalla <msanalla@xxxxxxxxxx>
Reviewed-by: Mark Bloch <mbloch@xxxxxxxxxx>
Signed-off-by: Michael Guralnik <michaelgur@xxxxxxxxxx>
---
 drivers/infiniband/core/device.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 0290aca18d26..583047457de2 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -2257,6 +2257,7 @@ struct net_device *ib_device_get_netdev(struct ib_device *ib_dev,
 	 * propagation of an unregistering netdev.
 	 */
 	if (res && res->reg_state != NETREG_REGISTERED) {
+		ib_device_set_netdev(ib_dev, NULL, port);
 		dev_put(res);
 		return NULL;
 	}
-- 
2.17.2





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux