[PATCH] makedumpfile: Fix the variable pfn_needed leaking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If the page pfn calculated by read_from_splitblock_table is bigger than
pfn_needed, the variable pfn_needed will leak.

makedumpfile cannot assign the pfn averagely bacause of condition
pfn_needed invalid.

Signed-off-by: Minfei Huang <mhuang at redhat.com>
---
 makedumpfile.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index 59c4952..8807a90 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -8415,7 +8415,7 @@ calculate_end_pfn_by_splitblock(mdf_pfn_t start_pfn,
 		return info->max_mapnr;
 
 	mdf_pfn_t end_pfn;
-	long long pfn_needed, offset;
+	long long pfn_needed, offset, per_splitblock_pfn;
 	char *splitblock_value_offset;
 
 	pfn_needed = info->num_dumpable / info->num_dumpfile;
@@ -8424,7 +8424,8 @@ calculate_end_pfn_by_splitblock(mdf_pfn_t start_pfn,
 	end_pfn = start_pfn;
 
 	while (*cur_splitblock_num < splitblock->num && pfn_needed > 0) {
-		pfn_needed -= read_from_splitblock_table(splitblock_value_offset);
+		per_splitblock_pfn = read_from_splitblock_table(splitblock_value_offset); 
+		pfn_needed = pfn_needed < per_splitblock_pfn ? 0 : pfn_needed - per_splitblock_pfn;
 		splitblock_value_offset += splitblock->entry_size;
 		++*cur_splitblock_num;
 	}
-- 
1.8.3.1




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux