Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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@uniontech.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

authored by

Morduan Zang and committed by
Ard Biesheuvel
d7f1b4bd 85829b80

+1 -1
+1 -1
drivers/firmware/efi/cper.c
··· 162 162 len -= size; 163 163 str += size; 164 164 } 165 - return len - buf_size; 165 + return buf_size - len; 166 166 } 167 167 EXPORT_SYMBOL_GPL(cper_bits_to_str); 168 168