Skip to content

Commit c295160

Browse files
Hao ChenPaolo Abeni
authored andcommitted
net: hns3: fix debugfs concurrency issue between kfree buffer and read
Now in hns3_dbg_uninit(), there may be concurrency between kfree buffer and read, it may result in memory error. Moving debugfs_remove_recursive() in front of kfree buffer to ensure they don't happen at the same time. Fixes: 5e69ea7 ("net: hns3: refactor the debugfs process") Signed-off-by: Hao Chen <chenhao418@huawei.com> Signed-off-by: Jijie Shao <shaojijie@huawei.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent efccf65 commit c295160

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,25 +1415,26 @@ int hns3_dbg_init(struct hnae3_handle *handle)
14151415
return 0;
14161416

14171417
out:
1418-
mutex_destroy(&handle->dbgfs_lock);
14191418
debugfs_remove_recursive(handle->hnae3_dbgfs);
14201419
handle->hnae3_dbgfs = NULL;
1420+
mutex_destroy(&handle->dbgfs_lock);
14211421
return ret;
14221422
}
14231423

14241424
void hns3_dbg_uninit(struct hnae3_handle *handle)
14251425
{
14261426
u32 i;
14271427

1428+
debugfs_remove_recursive(handle->hnae3_dbgfs);
1429+
handle->hnae3_dbgfs = NULL;
1430+
14281431
for (i = 0; i < ARRAY_SIZE(hns3_dbg_cmd); i++)
14291432
if (handle->dbgfs_buf[i]) {
14301433
kvfree(handle->dbgfs_buf[i]);
14311434
handle->dbgfs_buf[i] = NULL;
14321435
}
14331436

14341437
mutex_destroy(&handle->dbgfs_lock);
1435-
debugfs_remove_recursive(handle->hnae3_dbgfs);
1436-
handle->hnae3_dbgfs = NULL;
14371438
}
14381439

14391440
void hns3_dbg_register_debugfs(const char *debugfs_dir_name)

0 commit comments

Comments
 (0)