drivers/md/md-bitmap: check the return value of md_bitmap_get_counter()
[ Upstream commit 3bd548e5b8 ]
Check the return value of md_bitmap_get_counter() in case it returns
NULL pointer, which will result in a null pointer dereference.
v2: update the check to include other dereference
Signed-off-by: Li Zhong <floridsleeves@gmail.com>
Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
7d86851c30
commit
100caacfa0
1 changed files with 15 additions and 12 deletions
|
|
@ -2196,20 +2196,23 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
|
||||||
|
|
||||||
if (set) {
|
if (set) {
|
||||||
bmc_new = md_bitmap_get_counter(&bitmap->counts, block, &new_blocks, 1);
|
bmc_new = md_bitmap_get_counter(&bitmap->counts, block, &new_blocks, 1);
|
||||||
if (*bmc_new == 0) {
|
if (bmc_new) {
|
||||||
/* need to set on-disk bits too. */
|
if (*bmc_new == 0) {
|
||||||
sector_t end = block + new_blocks;
|
/* need to set on-disk bits too. */
|
||||||
sector_t start = block >> chunkshift;
|
sector_t end = block + new_blocks;
|
||||||
start <<= chunkshift;
|
sector_t start = block >> chunkshift;
|
||||||
while (start < end) {
|
|
||||||
md_bitmap_file_set_bit(bitmap, block);
|
start <<= chunkshift;
|
||||||
start += 1 << chunkshift;
|
while (start < end) {
|
||||||
|
md_bitmap_file_set_bit(bitmap, block);
|
||||||
|
start += 1 << chunkshift;
|
||||||
|
}
|
||||||
|
*bmc_new = 2;
|
||||||
|
md_bitmap_count_page(&bitmap->counts, block, 1);
|
||||||
|
md_bitmap_set_pending(&bitmap->counts, block);
|
||||||
}
|
}
|
||||||
*bmc_new = 2;
|
*bmc_new |= NEEDED_MASK;
|
||||||
md_bitmap_count_page(&bitmap->counts, block, 1);
|
|
||||||
md_bitmap_set_pending(&bitmap->counts, block);
|
|
||||||
}
|
}
|
||||||
*bmc_new |= NEEDED_MASK;
|
|
||||||
if (new_blocks < old_blocks)
|
if (new_blocks < old_blocks)
|
||||||
old_blocks = new_blocks;
|
old_blocks = new_blocks;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue