RDMA/core: Use refcount_t instead of atomic_t on refcount of iwpm_admin_data
authorWeihang Li <liweihang@huawei.com>
Fri, 28 May 2021 09:37:33 +0000 (17:37 +0800)
committerJason Gunthorpe <jgg@nvidia.com>
Tue, 8 Jun 2021 17:36:24 +0000 (14:36 -0300)
commitfcc57a7b2bba3374da1b7df3f65aec35dac37917
tree6b282a359ebe9b840dff5d2ef277bc607b4ed3d7
parent60dff56d77292062789232f68354f567e1ccf1d2
RDMA/core: Use refcount_t instead of atomic_t on refcount of iwpm_admin_data

The refcount_t API will WARN on underflow and overflow of a reference
counter, and avoid use-after-free risks. Increase refcount_t from 0 to 1 is
regarded as there is a risk about use-after-free. So it should be set to 1
directly during initialization.

Link: https://lore.kernel.org/r/1622194663-2383-3-git-send-email-liweihang@huawei.com
Signed-off-by: Weihang Li <liweihang@huawei.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/infiniband/core/iwpm_util.c
drivers/infiniband/core/iwpm_util.h