From: NeilBrown Date: Thu, 2 Jun 2016 06:19:52 +0000 (+1000) Subject: md/raid10: add rcu protection in raid10_status. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d44b0a928fa9925fb453d7acc42a48c79de2c6f7;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git md/raid10: add rcu protection in raid10_status. mirrors[].rdev can become NULL at any point unless: - a counted reference is held - ->reconfig_mutex is held, or - rcu_read_lock() is held raid10_status holds none of these. So add rcu_read_lock() protection. Signed-off-by: NeilBrown Signed-off-by: Shaohua Li --- diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 6044864feb7b..334a701902de 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1495,10 +1495,12 @@ static void raid10_status(struct seq_file *seq, struct mddev *mddev) } seq_printf(seq, " [%d/%d] [", conf->geo.raid_disks, conf->geo.raid_disks - mddev->degraded); - for (i = 0; i < conf->geo.raid_disks; i++) - seq_printf(seq, "%s", - conf->mirrors[i].rdev && - test_bit(In_sync, &conf->mirrors[i].rdev->flags) ? "U" : "_"); + rcu_read_lock(); + for (i = 0; i < conf->geo.raid_disks; i++) { + struct md_rdev *rdev = rcu_dereference(conf->mirrors[i].rdev); + seq_printf(seq, "%s", rdev && test_bit(In_sync, &rdev->flags) ? "U" : "_"); + } + rcu_read_unlock(); seq_printf(seq, "]"); }