IB/cm: Split cm_alloc_msg()
authorJason Gunthorpe <jgg@nvidia.com>
Wed, 2 Jun 2021 10:27:02 +0000 (13:27 +0300)
committerJason Gunthorpe <jgg@nvidia.com>
Wed, 2 Jun 2021 18:41:57 +0000 (15:41 -0300)
commit4b4e586ebe37c8c7e2a4bf46dc4b742756fd788d
treebdab0dbe2836a5a61c1d1ef340e182a300479ddc
parent96376a40959e32502208210c62e68a6c60acfb48
IB/cm: Split cm_alloc_msg()

This is being used with two quite different flows, one attaches the
message to the priv and the other does not.

Ensure the message attach is consistently done under the spinlock and
ensure that the free on error always detaches the message from the
cm_id_priv, also always under lock.

This makes read/write to the cm_id_priv->msg consistently locked and
consistently NULL'd when the message is freed, even in all error paths.

Link: https://lore.kernel.org/r/f692b8c89eecb34fd82244f317e478bea6c97688.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