]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
efi/cper: Fix cper_bits_to_str buffer handling and return value
authorMorduan Zang <zhangdandan@uniontech.com>
Wed, 14 Jan 2026 05:30:33 +0000 (13:30 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:12:12 +0000 (13:12 +0100)
commit43fb1cf4e7816bc12fa6292176d9bf2f9caddb87
tree0a0d6e1c56b2302ec9b86cae338cd2cbd286c807
parent7888b5f64294d6ecd013341d09f68437458b10c6
efi/cper: Fix cper_bits_to_str buffer handling and return value

commit d7f1b4bdc7108be1b178e1617b5f45c8918e88d7 upstream.

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@uniontech.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/firmware/efi/cper.c