summaryrefslogtreecommitdiff
path: root/drivers/firmware
diff options
context:
space:
mode:
authorMorduan Zang <zhangdandan@uniontech.com>2026-01-14 13:30:33 +0800
committerArd Biesheuvel <ardb@kernel.org>2026-01-14 11:34:42 +0100
commitd7f1b4bdc7108be1b178e1617b5f45c8918e88d7 (patch)
treeed2fa3f5c8ccc4c441d9c6c9b6e3492abe3e4d22 /drivers/firmware
parent85829b80ca29d3ac6c1770dbe12306a1d960a8ac (diff)
downloadlinux-next-d7f1b4bdc7108be1b178e1617b5f45c8918e88d7.tar.gz
linux-next-d7f1b4bdc7108be1b178e1617b5f45c8918e88d7.zip
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>
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/efi/cper.c2
1 files changed, 1 insertions, 1 deletions
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);