From: Hugh Dickins Date: Thu, 7 Dec 2006 04:39:20 +0000 (-0800) Subject: [PATCH] ext4 balloc: fix off-by-one against rsv_end X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b2f2c76d17b68869914a1ec3ab04c7674668f60d;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git [PATCH] ext4 balloc: fix off-by-one against rsv_end rsv_end is the last block within the reservation, so alloc_new_reservation should accept start_block == rsv_end as success. Signed-off-by: Mingming Cao Signed-off-by: Hugh Dickins Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 2bcca5261eeb..c5589b3f58e8 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c @@ -1165,7 +1165,7 @@ retry: * check if the first free block is within the * free space we just reserved */ - if (start_block >= my_rsv->rsv_start && start_block < my_rsv->rsv_end) + if (start_block >= my_rsv->rsv_start && start_block <= my_rsv->rsv_end) return 0; /* success */ /* * if the first free bit we found is out of the reservable space