driver inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I87LCF
--------------------------------------------------------------------------
When unregistering the device or destroying of ucontext and accessing dca debugfs concurrently, there may be a problem of accessing a null pointer.
This patch fixes it by delaying the pointer assignment to null until debugfs has been unregistered.
Fixes: a21781182f77 ("RDMA/hns: Add debugfs support for DCA") Signed-off-by: Chengchang Tang tangchengchang@huawei.com --- drivers/infiniband/hw/hns/hns_roce_debugfs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/hw/hns/hns_roce_debugfs.c b/drivers/infiniband/hw/hns/hns_roce_debugfs.c index 8df480aa37a4..35d81e7546ed 100644 --- a/drivers/infiniband/hw/hns/hns_roce_debugfs.c +++ b/drivers/infiniband/hw/hns/hns_roce_debugfs.c @@ -525,8 +525,8 @@ void hns_roce_unregister_uctx_debugfs(struct hns_roce_dev *hr_dev, struct hns_dca_ctx_debugfs *dbgfs = uctx->dca_dbgfs;
if (dbgfs) { - uctx->dca_dbgfs = NULL; cleanup_dca_ctx_debugfs(dbgfs); + uctx->dca_dbgfs = NULL; kfree(dbgfs); } } @@ -567,14 +567,13 @@ void hns_roce_unregister_debugfs(struct hns_roce_dev *hr_dev) if (!dbgfs) return;
- hr_dev->dbgfs = NULL; - if (dbgfs->dca_root) { destroy_dca_debugfs(dbgfs->dca_root); dbgfs->dca_root = NULL; }
debugfs_remove_recursive(dbgfs->root); + hr_dev->dbgfs = NULL; kfree(dbgfs); }