lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 21 Jun 2022 15:02:24 +0800
From:   Shida Zhang <starzhangzsd@...il.com>
To:     djwong@...nel.org, dchinner@...hat.com
Cc:     zhangshida@...inos.cn, starzhangzsd@...il.com,
        linux-kernel@...r.kernel.org, linux-xfs@...r.kernel.org
Subject: [PATCH v2] xfs: add check before calling xfs_mod_fdblocks

Checks are missing when delta equals 0 in __xfs_ag_resv_free() and
__xfs_ag_resv_init().

Signed-off-by: Shida Zhang <zhangshida@...inos.cn>
---
 Changes from v1:
 -Add checks before calling xfs_mod_fdblocks instead.

 fs/xfs/libxfs/xfs_ag_resv.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c
index fe94058d4e9e..c8fa032e4b00 100644
--- a/fs/xfs/libxfs/xfs_ag_resv.c
+++ b/fs/xfs/libxfs/xfs_ag_resv.c
@@ -149,7 +149,12 @@ __xfs_ag_resv_free(
 		oldresv = resv->ar_orig_reserved;
 	else
 		oldresv = resv->ar_reserved;
-	error = xfs_mod_fdblocks(pag->pag_mount, oldresv, true);
+
+	if (oldresv)
+		error = xfs_mod_fdblocks(pag->pag_mount, oldresv, true);
+	else
+		error = 0;
+
 	resv->ar_reserved = 0;
 	resv->ar_asked = 0;
 	resv->ar_orig_reserved = 0;
@@ -215,8 +220,13 @@ __xfs_ag_resv_init(
 
 	if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_AG_RESV_FAIL))
 		error = -ENOSPC;
-	else
-		error = xfs_mod_fdblocks(mp, -(int64_t)hidden_space, true);
+	else {
+		error = 0;
+		if (hidden_space)
+			error = xfs_mod_fdblocks(mp, -(int64_t)hidden_space,
+						true);
+	}
+
 	if (error) {
 		trace_xfs_ag_resv_init_error(pag->pag_mount, pag->pag_agno,
 				error, _RET_IP_);
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ