From: Aditya Pakki Date: Mon, 4 Mar 2019 22:48:54 +0000 (-0600) Subject: md: Fix failed allocation of md_register_thread X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=e406f12dde1a8375d77ea02d91f313fb1a9c6aec;p=openwrt%2Fstaging%2Fblogic.git md: Fix failed allocation of md_register_thread 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 Signed-off-by: Aditya Pakki Signed-off-by: Song Liu --- diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index ecef42bfe19d..3b6880dd648d 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -3939,6 +3939,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 09562d7cc080..992fd08437d8 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -7403,6 +7403,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 */