Commit e62daf7f authored by Guangwei Zhang's avatar Guangwei Zhang Committed by mufengyan
Browse files

Fix the issue that the debugfs query inconsistency.

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


CVE: NA

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

This patch modifies the implementation of debugfs:
When the user process stops unexpectedly, not all data of debugfs 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: 97d2f809 ("UNIC: Debugfs supports query of ip and guid table's list and specification")
Signed-off-by: default avatarGuangwei Zhang <zhangwangwei6@huawei.com>
parent 8f2643bd
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -136,8 +136,10 @@ static ssize_t hns3_unic_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_unic_dbg_read_cmd(dbg_data, ub_dbg_cmd[index].cmd,
					     read_buf,
					     ub_dbg_cmd[index].buf_len);