[PATCH] dm-zoned: Fix overflow in exposed capacity

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Cast unsigned int to sector_t before shifting. Otherwise, the target
length overflows and becomes incorrect.

Also fix an incorrect setting of the target suspend
operation.

Signed-off-by: Damien Le Moal <damien.lemoal@xxxxxxx>
---
 drivers/md/dm-zoned-target.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
index 4438f30..f947166 100644
--- a/drivers/md/dm-zoned-target.c
+++ b/drivers/md/dm-zoned-target.c
@@ -773,7 +773,7 @@ static int dmz_ctr(struct dm_target *ti, unsigned int argc, char **argv)
 	ti->split_discard_bios = true;
 
 	/* The exposed capacity is the number of chunks that can be mapped */
-	ti->len = dmz_nr_chunks(dmz->metadata) << dev->zone_nr_sectors_shift;
+	ti->len = (sector_t)dmz_nr_chunks(dmz->metadata) << dev->zone_nr_sectors_shift;
 
 	/* Zone BIO */
 	dmz->bio_set = bioset_create_nobvec(DMZ_MIN_BIOS, 0);
@@ -944,7 +944,8 @@ static struct target_type dmz_type = {
 	.end_io		 = dmz_end_io,
 	.io_hints	 = dmz_io_hints,
 	.prepare_ioctl	 = dmz_prepare_ioctl,
-	.suspend	 = dmz_suspend,
+	.presuspend	 = dmz_suspend,
+	.presuspend_undo = dmz_resume,
 	.resume		 = dmz_resume,
 	.iterate_devices = dmz_iterate_devices,
 };
-- 
2.9.4

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel



[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux