diff options
author | Christoph Hellwig <hch@lst.de> | 2021-09-14 09:06:55 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-09-14 20:03:30 -0600 |
commit | 783a40a1b3ac7f3714d2776fa8ac8cce3535e4f6 (patch) | |
tree | bc9ed35cb80f91b84d1974ea8272c5525af2eddb | |
parent | 67f3b2f822b7e71cfc9b42dbd9f3144fa2933e0b (diff) | |
download | linux-stable-783a40a1b3ac7f3714d2776fa8ac8cce3535e4f6.tar.gz linux-stable-783a40a1b3ac7f3714d2776fa8ac8cce3535e4f6.tar.bz2 linux-stable-783a40a1b3ac7f3714d2776fa8ac8cce3535e4f6.zip |
block: check if a profile is actually registered in blk_integrity_unregister
While clearing the profile itself is harmless, we really should not clear
the stable writes flag if it wasn't set due to a registered integrity
profile.
Reported-by: Lihong Kou <koulihong@huawei.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Link: https://lore.kernel.org/r/20210914070657.87677-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | block/blk-integrity.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/block/blk-integrity.c b/block/blk-integrity.c index 69a12177dfb6..48bfb53aa857 100644 --- a/block/blk-integrity.c +++ b/block/blk-integrity.c @@ -426,8 +426,12 @@ EXPORT_SYMBOL(blk_integrity_register); */ void blk_integrity_unregister(struct gendisk *disk) { + struct blk_integrity *bi = &disk->queue->integrity; + + if (!bi->profile) + return; blk_queue_flag_clear(QUEUE_FLAG_STABLE_WRITES, disk->queue); - memset(&disk->queue->integrity, 0, sizeof(struct blk_integrity)); + memset(bi, 0, sizeof(*bi)); } EXPORT_SYMBOL(blk_integrity_unregister); |