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>] [day] [month] [year] [list]
Message-Id: <20220124144247.34525-1-wonder_rock@126.com>
Date:   Mon, 24 Jan 2022 22:42:47 +0800
From:   wonder_rock@....com
To:     keescook@...omium.org, anton@...msg.org, ccross@...roid.com,
        tony.luck@...el.com
Cc:     linux-kernel@...r.kernel.org, Deyan Wang <wonder_rock@....com>
Subject: [PATCH] pstore/ram: Use reminder directly

From: Deyan Wang <wonder_rock@....com>

The remainder is more efficient, we directly use the remainder.

Signed-off-by: Deyan Wang <wonder_rock@....com>
---
 fs/pstore/ram_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c
index fe5305028c6e..69928a59e28b 100644
--- a/fs/pstore/ram_core.c
+++ b/fs/pstore/ram_core.c
@@ -61,8 +61,8 @@ static size_t buffer_start_add(struct persistent_ram_zone *prz, size_t a)
 
 	old = atomic_read(&prz->buffer->start);
 	new = old + a;
-	while (unlikely(new >= prz->buffer_size))
-		new -= prz->buffer_size;
+	if (unlikely(new >= prz->buffer_size))
+		new %= prz->buffer_size;
 	atomic_set(&prz->buffer->start, new);
 
 	if (!(prz->flags & PRZ_FLAG_NO_LOCK))
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ