Skip to content

Commit 81dcb27

Browse files
Morduan Zanggregkh
authored andcommitted
efi/cper: Fix cper_bits_to_str buffer handling and return value
commit d7f1b4b 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: a976d79 ("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>
1 parent 1f81939 commit 81dcb27

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/firmware/efi/cper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ int cper_bits_to_str(char *buf, int buf_size, unsigned long bits,
162162
len -= size;
163163
str += size;
164164
}
165-
return len - buf_size;
165+
return buf_size - len;
166166
}
167167
EXPORT_SYMBOL_GPL(cper_bits_to_str);
168168

0 commit comments

Comments
 (0)