Blob Blame History Raw
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Tue, 4 Aug 2020 13:16:45 +0300
Subject: [PATCH] md-cluster: Fix potential error pointer dereference in
 resize_bitmaps()
Git-commit: e8abe1de43dac658dacbd04a4543e0c988a8d386
Patch-mainline: v5.9
References: git-fixes

The error handling calls md_bitmap_free(bitmap) which checks for NULL
but will Oops if we pass an error pointer.  Let's set "bitmap" to NULL
on this error path.

Fixes: afd756286083 ("md-cluster/raid10: resize all the bitmaps before start reshape")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
Acked-by: NeilBrown <neilb@suse.com>

---
 drivers/md/md-cluster.c |    1 +
 1 file changed, 1 insertion(+)

--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -1144,6 +1144,7 @@ static int resize_bitmaps(struct mddev *
 		bitmap = get_bitmap_from_slot(mddev, i);
 		if (IS_ERR(bitmap)) {
 			pr_err("can't get bitmap from slot %d\n", i);
+			bitmap = NULL;
 			goto out;
 		}
 		counts = &bitmap->counts;