md: avoid invalid memory access for array sb->dev_roles
authorYufen Yu <yuyufen@huawei.com>
Wed, 30 Oct 2019 10:47:02 +0000 (18:47 +0800)
committerSong Liu <songliubraving@fb.com>
Tue, 12 Nov 2019 00:32:22 +0000 (16:32 -0800)
commit228fc7d76db68732677230a3c64337908fd298e3
tree6c92664f7db4b1f0e5a687b7415a356e38c6c8ae
parent5fa4f8bac9516b988d2ccd3f05f4267f8da24269
md: avoid invalid memory access for array sb->dev_roles

we need to gurantee 'desc_nr' valid before access array
of sb->dev_roles.

In addition, we should avoid .load_super always return '0'
when level is LEVEL_MULTIPATH, which is not expected.

Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1487373 ("Memory - illegal accesses")
Fixes: 6a5cb53aaa4e ("md: no longer compare spare disk superblock events in super_load")
Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Signed-off-by: Song Liu <songliubraving@fb.com>
drivers/md/md.c