From nobody Mon Nov 25 19:38:49 2024 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DDE31D4144; Fri, 25 Oct 2024 09:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.255 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729848987; cv=none; b=D5eEENYHkWkzk0bRH0bxE3oFtCScHeQMdxQY55wm7pBKEh+IhnWJEp+jAQSVdBcnCatwEicmfWxuO0UOoJIoG2JfL8tyw9MMNa0sC7eLnH+MWQZUO5ymVJCyFfe590UEM3c+Q1CBWhUWMmnPMEZu6k9bY/h1xmOAuCwESEYs2Uk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729848987; c=relaxed/simple; bh=OduBsRI+5brxvfecv14Oqo66NEhumOkOaeJWxOctJmc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UWHK34fzSRtbKqlKw+uWwCWjQftbP6VXv7zUVBVwiPFcR1Fiq8AQFdMe3JzWyR/xbxg9JC8BKI6PVR/B+SYnbwDKpJOxeHrGjjZZl5AbmI4sQ3/lIOKYFj1OFba5LbMuct3aYjijf83/N/p+fqRG8sCuNISJR8vp2gB0vTKxwbQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.255 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4XZd0C0fx4z1T7xV; Fri, 25 Oct 2024 17:34:19 +0800 (CST) Received: from kwepemm000007.china.huawei.com (unknown [7.193.23.189]) by mail.maildlp.com (Postfix) with ESMTPS id 4CA1218006C; Fri, 25 Oct 2024 17:36:23 +0800 (CST) Received: from localhost.localdomain (10.90.30.45) by kwepemm000007.china.huawei.com (7.193.23.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 25 Oct 2024 17:36:22 +0800 From: Jijie Shao To: , , , , , CC: , , , , , , , Subject: [PATCH V3 net 5/9] net: hns3: Resolved the issue that the debugfs query result is inconsistent. Date: Fri, 25 Oct 2024 17:29:34 +0800 Message-ID: <20241025092938.2912958-6-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20241025092938.2912958-1-shaojijie@huawei.com> References: <20241025092938.2912958-1-shaojijie@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm000007.china.huawei.com (7.193.23.189) Content-Type: text/plain; charset="utf-8" From: Hao Lan 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: 5e69ea7ee2a6 ("net: hns3: refactor the debugfs process") Signed-off-by: Hao Lan Signed-off-by: Guangwei Zhang Signed-off-by: Jijie Shao --- drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/n= et/ethernet/hisilicon/hns3/hns3_debugfs.c index 807eb3bbb11c..841e5af7b2be 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -1293,8 +1293,10 @@ static ssize_t hns3_dbg_read(struct file *filp, char= __user *buffer, =20 /* save the buffer addr until the last read operation */ *save_buf =3D read_buf; + } =20 - /* get data ready for the first time to read */ + /* get data ready for the first time to read */ + if (!*ppos) { ret =3D hns3_dbg_read_cmd(dbg_data, hns3_dbg_cmd[index].cmd, read_buf, hns3_dbg_cmd[index].buf_len); if (ret) --=20 2.33.0