]> git.baikalelectronics.ru Git - kernel.git/commit
RDMA/netlink: Fix locking around __ib_get_device_by_index
authorLeon Romanovsky <leonro@mellanox.com>
Mon, 1 Jan 2018 11:07:15 +0000 (13:07 +0200)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 2 Jan 2018 21:11:40 +0000 (14:11 -0700)
commitbcc922b0bfc7648da867d018c7126fbac5f39b2d
tree54b791e66ed3e93338982601d5f9eec8cad75e7d
parent5e8ead38502d7cb8b8028966a05c8b027890ea00
RDMA/netlink: Fix locking around __ib_get_device_by_index

Holding locks is mandatory when calling __ib_device_get_by_index,
otherwise there are races during the list iteration with device removal.

Since the locks are static to device.c, __ib_device_get_by_index can
never be called correctly by any user out side the file.

Make the function static and provide a safe function that gets the
correct locks and returns a kref'd pointer. Fix all callers.

Fixes: d5b08a0fd48e ("RDMA/netlink: Add nldev device doit implementation")
Fixes: 4dc8796efe29 ("RDMA/netlink: Implement nldev port doit callback")
Fixes: eedc8f194ffa ("RDMA/netlink: Add nldev port dumpit implementation")
Reviewed-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/core_priv.h
drivers/infiniband/core/device.c
drivers/infiniband/core/nldev.c