diff options
author | Aditya Pakki <pakki001@umn.edu> | 2019-03-05 01:48:54 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-03-23 22:10:11 +0300 |
commit | cc3b79d487e83481f15973d82edefc197dbf495e (patch) | |
tree | 840e1d4f465b103b74a5e5f9e3de978fc9690ace | |
parent | 01088750f25e0fdbe8508ee681ca20142dfdb2e6 (diff) | |
download | linux-cc3b79d487e83481f15973d82edefc197dbf495e.tar.xz |
md: Fix failed allocation of md_register_thread
commit e406f12dde1a8375d77ea02d91f313fb1a9c6aec upstream.
mddev->sync_thread can be set to NULL on kzalloc failure downstream.
The patch checks for such a scenario and frees allocated resources.
Committer node:
Added similar fix to raid5.c, as suggested by Guoqing.
Cc: stable@vger.kernel.org # v3.16+
Acked-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/md/raid10.c | 2 | ||||
-rw-r--r-- | drivers/md/raid5.c | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 9df1334608b7..25e97de36717 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3959,6 +3959,8 @@ static int raid10_run(struct mddev *mddev) set_bit(MD_RECOVERY_RUNNING, &mddev->recovery); mddev->sync_thread = md_register_thread(md_do_sync, mddev, "reshape"); + if (!mddev->sync_thread) + goto out_free_conf; } return 0; diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 45a3551d3afd..ae38895c44b2 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -7390,6 +7390,8 @@ static int raid5_run(struct mddev *mddev) set_bit(MD_RECOVERY_RUNNING, &mddev->recovery); mddev->sync_thread = md_register_thread(md_do_sync, mddev, "reshape"); + if (!mddev->sync_thread) + goto abort; } /* Ok, everything is just fine now */ |