]> git.baikalelectronics.ru Git - kernel.git/commit
orangefs: Fix the size of a memory allocation in orangefs_bufmap_alloc()
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Mon, 27 Dec 2021 18:09:18 +0000 (19:09 +0100)
committerMike Marshall <hubcap@omnibond.com>
Fri, 31 Dec 2021 19:37:43 +0000 (14:37 -0500)
commit1b4f334089a0d8db7945f15543c24d062045bf1c
tree0ed299ebede8d2a197bd4e779d0b42d84b3ae730
parent3c4142233fdd7d3b0e89cc7463af95cea9021db4
orangefs: Fix the size of a memory allocation in orangefs_bufmap_alloc()

'buffer_index_array' really looks like a bitmap. So it should be allocated
as such.
When kzalloc is called, a number of bytes is expected, but a number of
longs is passed instead.

In get(), if not enough memory is allocated, un-allocated memory may be
read or written.

So use bitmap_zalloc() to safely allocate the correct memory size and
avoid un-expected behavior.

While at it, change the corresponding kfree() into bitmap_free() to keep
the semantic.

Fixes: bf159f8c0a0c ("orangefs: bufmap rewrite")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
fs/orangefs/orangefs-bufmap.c