From: Mikulas Patocka Date: Wed, 20 Jan 2021 11:02:31 +0000 (-0500) Subject: dm integrity: fix a crash if "recalculate" used without "internal_hash" X-Git-Tag: accepted/tizen/unified/20230118.172025~8036^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2d06dfecb132a1cc2e374a44eae83b5c4356b8b4;p=platform%2Fkernel%2Flinux-rpi.git dm integrity: fix a crash if "recalculate" used without "internal_hash" Recalculate can only be specified with internal_hash. Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Mikulas Patocka Signed-off-by: Mike Snitzer --- diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 81df019..cce203a 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -4235,6 +4235,12 @@ try_smaller_buffer: r = -ENOMEM; goto bad; } + } else { + if (ic->sb->flags & cpu_to_le32(SB_FLAG_RECALCULATING)) { + ti->error = "Recalculate can only be specified with internal_hash"; + r = -EINVAL; + goto bad; + } } ic->bufio = dm_bufio_client_create(ic->meta_dev ? ic->meta_dev->bdev : ic->dev->bdev,