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]
Message-ID: <7E55C4CEDE596906+20260114053033.124359-1-zhangdandan@uniontech.com>
Date: Wed, 14 Jan 2026 13:30:33 +0800
From: Morduan Zang <zhangdandan@...ontech.com>
To: ardb@...nel.org,
	linux-efi@...r.kernel.org,
	linux-kernel@...r.kernel.org
Cc: guanwentao@...ontech.com,
	zhangdandan@...ontech.com,
	niecheng1@...ontech.com
Subject: [PATCH] efi/cper: Fix cper_bits_to_str buffer handling and return value

The return value calculation was incorrect:
    `return len - buf_size;`
    Initially `len = buf_size`, then `len` decreases with each operation.
    This results in a negative return value on success.

Fix by returning `buf_size - len` which correctly calculates the
    actual number of bytes written.

Fixes: a976d790f494 ("efi/cper: Add a new helper function to print bitmasks")
Signed-off-by: Morduan Zang <zhangdandan@...ontech.com>
---
 drivers/firmware/efi/cper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
index 0232bd040f61..bd99802cb0ca 100644
--- a/drivers/firmware/efi/cper.c
+++ b/drivers/firmware/efi/cper.c
@@ -162,7 +162,7 @@ int cper_bits_to_str(char *buf, int buf_size, unsigned long bits,
 		len -= size;
 		str += size;
 	}
-	return len - buf_size;
+	return buf_size - len;
 }
 EXPORT_SYMBOL_GPL(cper_bits_to_str);
 
-- 
2.50.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ