Skip to content

Commit 072623d

Browse files
Mikulas Patockasnitm
authored andcommitted
dm: fix dm_target_io leak if clone_bio() returns an error
Commit c80914e ("dm: return error if bio_integrity_clone() fails in clone_bio()") changed clone_bio() such that if it does return error then the alloc_tio() created resources (both the bio that was allocated to be a clone and the containing dm_target_io struct) will leak. Fix this by calling free_tio() in __clone_and_map_data_bio()'s clone_bio() error path. Fixes: c80914e ("dm: return error if bio_integrity_clone() fails in clone_bio()") Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
1 parent bf16200 commit 072623d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/md/dm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1662,8 +1662,10 @@ static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti,
16621662
tio = alloc_tio(ci, ti, target_bio_nr);
16631663
tio->len_ptr = len;
16641664
r = clone_bio(tio, bio, sector, *len);
1665-
if (r < 0)
1665+
if (r < 0) {
1666+
free_tio(ci->md, tio);
16661667
break;
1668+
}
16671669
__map_bio(tio);
16681670
}
16691671

0 commit comments

Comments
 (0)