Commit 04180b7a authored by Juan Zhou's avatar Juan Zhou
Browse files

RDMA/hns: Fix memory leak in POE debugfs

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I8OLBT



--------------------------------------------------------------------------

In the init_poe_ch_debugfs() function, the variable dbgfs can be
directly read without applying for additional memory. Otherwise,
memory leakage may occur.

Fixes: b6643496 ("RDMA/hns: Refactor hns RoCE debugfs")
Signed-off-by: default avatarJuan Zhou <zhoujuan51@h-partners.com>
Signed-off-by: default avatarJunxian Huang <huangjunxian6@hisilicon.com>
parent 42d7d2ee
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -557,14 +557,10 @@ static void init_poe_ch_debugfs(struct hns_roce_dev *hr_dev, uint8_t index,
				struct dentry *parent)
{
#define POE_CH_NAME_LEN 10
	struct hns_poe_ch_debugfs *dbgfs = &hr_dev->dbgfs.poe_root.poe_ch[index];
	struct hns_roce_poe_ch *poe_ch = &hr_dev->poe_ctx.poe_ch[index];
	struct hns_poe_ch_debugfs *dbgfs;
	char name[POE_CH_NAME_LEN];

	dbgfs = kvzalloc(sizeof(*dbgfs), GFP_KERNEL);
	if (!dbgfs)
		return;

	snprintf(name, sizeof(name), "poe_%u", index);
	dbgfs->root = debugfs_create_dir(name, parent);