Skip to content

Commit 2758f18

Browse files
Hao LanPaolo Abeni
authored andcommitted
net: hns3: Resolved the issue that the debugfs query result is inconsistent.
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: 5e69ea7 ("net: hns3: refactor the debugfs process") Signed-off-by: Hao Lan <[email protected]> Signed-off-by: Guangwei Zhang <[email protected]> Signed-off-by: Jijie Shao <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent 662ecfc commit 2758f18

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,8 +1293,10 @@ static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
12931293

12941294
/* save the buffer addr until the last read operation */
12951295
*save_buf = read_buf;
1296+
}
12961297

1297-
/* get data ready for the first time to read */
1298+
/* get data ready for the first time to read */
1299+
if (!*ppos) {
12981300
ret = hns3_dbg_read_cmd(dbg_data, hns3_dbg_cmd[index].cmd,
12991301
read_buf, hns3_dbg_cmd[index].buf_len);
13001302
if (ret)

0 commit comments

Comments
 (0)