md: call __md_stop_writes in md_stop
authorGuoqing Jiang <guoqing.jiang@linux.dev>
Wed, 17 Aug 2022 12:05:14 +0000 (20:05 +0800)
committerSong Liu <song@kernel.org>
Wed, 24 Aug 2022 18:19:59 +0000 (11:19 -0700)
From the link [1], we can see raid1d was running even after the path
raid_dtr -> md_stop -> __md_stop.

Let's stop write first in destructor to align with normal md-raid to
fix the KASAN issue.

[1]. https://lore.kernel.org/linux-raid/CAPhsuW5gc4AakdGNdF8ubpezAuDLFOYUO_sfMZcec6hQFm8nhg@mail.gmail.com/T/#m7f12bf90481c02c6d2da68c64aeed4779b7df74a

Fixes: 48df498daf62 ("md: move bitmap_destroy to the beginning of __md_stop")
Reported-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Signed-off-by: Song Liu <song@kernel.org>
drivers/md/md.c

index 107c4c953c35a91e2093f9dad2496b30c048d997..729be2c5296c6c3544abaa7701e3d7b8fa7f9f43 100644 (file)
@@ -6261,6 +6261,7 @@ void md_stop(struct mddev *mddev)
        /* stop the array and free an attached data structures.
         * This is called from dm-raid
         */
+       __md_stop_writes(mddev);
        __md_stop(mddev);
        bioset_exit(&mddev->bio_set);
        bioset_exit(&mddev->sync_set);