Skip to content

Commit 1963bdb

Browse files
Christoph Hellwiggregkh
authored andcommitted
block: check if a profile is actually registered in blk_integrity_unregister
[ 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>
1 parent 526261c commit 1963bdb

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎block/blk-integrity.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,12 @@ EXPORT_SYMBOL(blk_integrity_register);
426426
*/
427427
void blk_integrity_unregister(struct gendisk *disk)
428428
{
429+
struct blk_integrity *bi = &disk->queue->integrity;
430+
431+
if (!bi->profile)
432+
return;
429433
blk_queue_flag_clear(QUEUE_FLAG_STABLE_WRITES, disk->queue);
430-
memset(&disk->queue->integrity, 0, sizeof(struct blk_integrity));
434+
memset(bi, 0, sizeof(*bi));
431435
}
432436
EXPORT_SYMBOL(blk_integrity_unregister);
433437

0 commit comments

Comments
 (0)