Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/device: Remove optimization in ib_device_get_netdev()

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, remove this optimization and return the netdev even if
it 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.

Signed-off-by: Maher Sanalla <msanalla@nvidia.com>
Signed-off-by: Chiara Meiohas <cmeiohas@nvidia.com>
Signed-off-by: Michael Guralnik <michaelgur@nvidia.com>
Link: https://patch.msgid.link/20240909173025.30422-5-michaelgur@nvidia.com
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>

authored by

Chiara Meiohas and committed by
Leon Romanovsky
5f8ca04f 91b4b2c6

-9
-9
drivers/infiniband/core/device.c
··· 2252 2252 spin_unlock(&pdata->netdev_lock); 2253 2253 } 2254 2254 2255 - /* 2256 - * If we are starting to unregister expedite things by preventing 2257 - * propagation of an unregistering netdev. 2258 - */ 2259 - if (res && res->reg_state != NETREG_REGISTERED) { 2260 - dev_put(res); 2261 - return NULL; 2262 - } 2263 - 2264 2255 return res; 2265 2256 } 2266 2257