Skip to content

Commit

Permalink
block: bvec_nr_vecs() returns value for wrong slab
Browse files Browse the repository at this point in the history
[ Upstream commit d6c02a9 ]

In commit ed996a5 ("block: simplify and cleanup bvec pool
handling"), the value of the slab index is incremented by one in
bvec_alloc() after the allocation is done to indicate an index value of
0 does not need to be later freed.

bvec_nr_vecs() was not updated accordingly, and thus returns the wrong
value.  Decrement idx before performing the lookup.

Fixes: ed996a5 ("block: simplify and cleanup bvec pool handling")
Signed-off-by: Greg Edwards <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
g-edwards authored and gregkh committed Sep 15, 2018
1 parent 6952b4e commit d67c7c9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion block/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static void bio_put_slab(struct bio_set *bs)

unsigned int bvec_nr_vecs(unsigned short idx)
{
return bvec_slabs[idx].nr_vecs;
return bvec_slabs[--idx].nr_vecs;
}

void bvec_free(mempool_t *pool, struct bio_vec *bv, unsigned int idx)
Expand Down

0 comments on commit d67c7c9

Please sign in to comment.