[RHEL8,COMMIT] cbt: Fix off-by-one in map_required_size()

Submitted by Konstantin Khorenko on Dec. 10, 2019, 3:48 p.m.

Details

Message ID 201912101548.xBAFmuW2024415@finist_co8.work.ct
State New
Series "cbt: Fix off-by-one in map_required_size()"
Headers show

Commit Message

Konstantin Khorenko Dec. 10, 2019, 3:48 p.m.
The commit is pushed to "branch-rh8-4.18.0-80.1.2.vz8.2.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-80.1.2.vz8.2.6
------>
commit 6ce997aec3e18eea09ec6d851540c2a570fb319f
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Tue Dec 10 18:48:56 2019 +0300

    cbt: Fix off-by-one in map_required_size()
    
    find_last_bit() returns bit number, while we need
    bits amount.
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 block/blk-cbt.c | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/block/blk-cbt.c b/block/blk-cbt.c
index 171d3b5869b4..9d3a77fc3e56 100644
--- a/block/blk-cbt.c
+++ b/block/blk-cbt.c
@@ -326,6 +326,8 @@  static unsigned long map_required_size(struct page **map, unsigned long block_ma
 	bit = find_last_bit(page_address(map[page - 1]), PAGE_SIZE);
 	if (bit >= PAGE_SIZE)
 		bit = 0; /* Not found */
+	else
+		bit++;
 
 	return DIV_ROUND_UP(bit, 8) + page * PAGE_SIZE;
 }