Commit e406f12d authored by Aditya Pakki's avatar Aditya Pakki Committed by Song Liu
Browse files

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: default avatarGuoqing Jiang <gqjiang@suse.com>
Signed-off-by: default avatarAditya Pakki <pakki001@umn.edu>
Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
parent b761dcf1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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;
+2 −0
Original line number Diff line number Diff line
@@ -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 */