md: Fix failed allocation of md_register_thread
authorAditya Pakki <pakki001@umn.edu>
Mon, 4 Mar 2019 22:48:54 +0000 (16:48 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Mar 2019 07:19:03 +0000 (08:19 +0100)
commit73929a01c5659088b6a4aa54a2bc131b89dbfc0b
treea9afbf20bcbd4437b6c984eb2e5bea54873f503f
parent3127b10f2e45739f532f6b3b15f2c8187c0904d6
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>
drivers/md/raid10.c
drivers/md/raid5.c