IB/cm: Protect cm_dev, cm_ports and mad_agent with kref and lock
authorMark Zhang <markzhang@nvidia.com>
Wed, 2 Jun 2021 10:27:08 +0000 (13:27 +0300)
committerJason Gunthorpe <jgg@nvidia.com>
Wed, 2 Jun 2021 18:41:58 +0000 (15:41 -0300)
commit76039ac9095f5ee5ec7fb95ccb6a5460d5f8c3a2
treedd9b0fca05125e53bb0c7eab30ce7eb344f89150
parent7345201c39633fc4c82dae7315da7154efaf2459
IB/cm: Protect cm_dev, cm_ports and mad_agent with kref and lock

During cm_dev deregistration in cm_remove_one(), the cm_device and
cm_ports will be freed, after that they should not be accessed. The
mad_agent needs to be protected as well.

This patch adds a cm_device kref to protect cm_dev and cm_ports, and a
mad_agent_lock spinlock to protect mad_agent.

Link: https://lore.kernel.org/r/501ba7a2ff203dccd0e6755d3f93329772adce52.1622629024.git.leonro@nvidia.com
Signed-off-by: Mark Zhang <markzhang@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/cm.c