mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v1] drivers/md/md-bitmap: check the return value of md_bitmap_get_counter()
@ 2022-09-09  4:09 Li Zhong
  2022-09-13  9:11 ` Dan Carpenter
  2022-10-20 17:47 ` Song Liu
  0 siblings, 2 replies; 3+ messages in thread
From: Li Zhong @ 2022-09-09  4:09 UTC (permalink / raw)
  To: linux-kernel, linux-raid; +Cc: song, Li Zhong

Check the return value of md_bitmap_get_counter() in case it returns
NULL pointer, which will result in a null pointer dereference.

Signed-off-by: Li Zhong <floridsleeves@gmail.com>
---
 drivers/md/md-bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
index bf6dffadbe6f..06ab1098ff99 100644
--- a/drivers/md/md-bitmap.c
+++ b/drivers/md/md-bitmap.c
@@ -2195,7 +2195,7 @@ int md_bitmap_resize(struct bitmap *bitmap, sector_t blocks,
 
 		if (set) {
 			bmc_new = md_bitmap_get_counter(&bitmap->counts, block, &new_blocks, 1);
-			if (*bmc_new == 0) {
+			if (bmc_new && *bmc_new == 0) {
 				/* need to set on-disk bits too. */
 				sector_t end = block + new_blocks;
 				sector_t start = block >> chunkshift;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-20 17:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-09  4:09 [PATCH v1] drivers/md/md-bitmap: check the return value of md_bitmap_get_counter() Li Zhong
2022-09-13  9:11 ` Dan Carpenter
2022-10-20 17:47 ` Song Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®