From: Dan Carpenter Date: Wed, 10 Dec 2014 23:41:37 +0000 (-0800) Subject: ocfs2: fix an off-by-one BUG_ON() statement X-Git-Tag: v5.15~16738^2~180 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=519a286175b6422e13694ebb73aefee0b5749443;p=platform%2Fkernel%2Flinux-starfive.git ocfs2: fix an off-by-one BUG_ON() statement The ->si_slots[] array is allocated in ocfs2_init_slot_info() it has "->max_slots" number of elements so this test should be >= instead of >. Static checker work. Compile tested only. Signed-off-by: Dan Carpenter Cc: Mark Fasheh Cc: Joel Becker Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c index a88b2a4..d5493e3 100644 --- a/fs/ocfs2/slot_map.c +++ b/fs/ocfs2/slot_map.c @@ -306,7 +306,7 @@ int ocfs2_slot_to_node_num_locked(struct ocfs2_super *osb, int slot_num, assert_spin_locked(&osb->osb_lock); BUG_ON(slot_num < 0); - BUG_ON(slot_num > osb->max_slots); + BUG_ON(slot_num >= osb->max_slots); if (!si->si_slots[slot_num].sl_valid) return -ENOENT;