mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
dm-integrity: fix a bug if the bio is out of limits
If dm_integrity_check_limits fails, the code would exit with
DM_MAPIO_KILL. However, the range would be already locked at this point,
and it wouldn't be unlocked, resulting in a deadlock. Let's move the
limit check up, so that when it exits, no resources are leaked.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Assisted-by: Claude:claude-opus-4.6
Fixes: fb0987682c ("dm-integrity: introduce the Inline mode")
Cc: stable@vger.kernel.org
This commit is contained in:
parent
edf025f083
commit
5a266764fa
|
|
@ -2520,6 +2520,9 @@ static int dm_integrity_map_inline(struct dm_integrity_io *dio, bool from_map)
|
|||
if (unlikely((bio->bi_opf & REQ_PREFLUSH) != 0))
|
||||
return DM_MAPIO_REMAPPED;
|
||||
|
||||
if (unlikely(!dm_integrity_check_limits(ic, bio->bi_iter.bi_sector, bio)))
|
||||
return DM_MAPIO_KILL;
|
||||
|
||||
retry:
|
||||
if (!dio->integrity_payload) {
|
||||
unsigned digest_size, extra_size;
|
||||
|
|
@ -2584,10 +2587,6 @@ static int dm_integrity_map_inline(struct dm_integrity_io *dio, bool from_map)
|
|||
|
||||
dio->bio_details.bi_iter = bio->bi_iter;
|
||||
|
||||
if (unlikely(!dm_integrity_check_limits(ic, bio->bi_iter.bi_sector, bio))) {
|
||||
return DM_MAPIO_KILL;
|
||||
}
|
||||
|
||||
bio->bi_iter.bi_sector += ic->start + SB_SECTORS;
|
||||
|
||||
bip = bio_integrity_alloc(bio, GFP_NOIO, 1);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user