Skip to content

Commit

Permalink
block: check if a profile is actually registered in blk_integrity_unr…
Browse files Browse the repository at this point in the history
…egister

[ Upstream commit 783a40a ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Christoph Hellwig authored and gregkh committed Sep 30, 2021
1 parent e7f8b50 commit 282aed1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion block/blk-integrity.c
Expand Up @@ -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);

Expand Down

0 comments on commit 282aed1

Please sign in to comment.