[PATCH v2 makedumpfile 1/3] Fix off by one error when checking cache_size
Benjamin Poirier
bpoirier at nvidia.com
Thu Jul 8 00:06:09 PDT 2021
Given the test in write_cache():
if (cd->buf_size < cd->cache_size)
return TRUE;
a write is done if buf_size == cache_size.
The test at the beginning of write_kdump_page() intends to detect cases
when write_cache() will do a write, however it was missing this boundary
condition. This would lead write_kdump_page() to ignore errors from
write_cache().
Signed-off-by: Benjamin Poirier <bpoirier at nvidia.com>
---
makedumpfile.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/makedumpfile.c b/makedumpfile.c
index fcb571f..aa05be7 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -7993,8 +7993,8 @@ write_kdump_page(struct cache_data *cd_header, struct cache_data *cd_page,
* write the buffer cd_header into dumpfile and then write the cd_page.
* With that, when enospc occurs, we can save more useful information.
*/
- if (cd_header->buf_size + sizeof(*pd) > cd_header->cache_size
- || cd_page->buf_size + pd->size > cd_page->cache_size){
+ if (cd_header->buf_size + sizeof(*pd) >= cd_header->cache_size ||
+ cd_page->buf_size + pd->size >= cd_page->cache_size) {
if( !write_cd_buf(cd_header) ) {
memset(cd_header->buf, 0, cd_header->cache_size);
write_cd_buf(cd_header);
--
2.32.0
More information about the kexec
mailing list