Commit 1c6df3ad authored by Hao Lan's avatar Hao Lan Committed by Hao Chen
Browse files

net: hns3: Resolved the issue that the debugfs query result is inconsistent.

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


CVE: NA

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

This patch modifies the implementation of debugfs:
When the user process stops unexpectedly, not all data of the file system
is read. In this case, the save_buf pointer is not released. When the user
process is called next time, save_buf is used to copy the cached data
to the user space. As a result, the queried data is inconsistent. To solve
this problem, determine whether the function is invoked for the first time
based on the value of *ppos. If *ppos is 0, obtain the actual data.

Fixes: c0d3248b ("net: hns3: refactor the debugfs process")
Signed-off-by: default avatarGuangwei Zhang <zhangwangwei6@huawei.com>
Signed-off-by: default avatarHao Lan <lanhao@huawei.com>
parent 3eaf1b6b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1298,8 +1298,10 @@ static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,

		/* save the buffer addr until the last read operation */
		*save_buf = read_buf;
	}

	/* get data ready for the first time to read */
	if (!*ppos) {
		ret = hns3_dbg_read_cmd(dbg_data, hns3_dbg_cmd[index].cmd,
					read_buf, hns3_dbg_cmd[index].buf_len);
		if (ret)