All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm-zoned: Fix overflow in exposed capacity
@ 2017-06-09  4:06 Damien Le Moal
  2017-06-09 12:03 ` Mike Snitzer
  0 siblings, 1 reply; 5+ messages in thread
From: Damien Le Moal @ 2017-06-09  4:06 UTC (permalink / raw)
  To: dm-devel, Mike Snitzer, Alasdair Kergon; +Cc: Bart Van Assche

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@wdc.com>
---
 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-06-13 23:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-09  4:06 [PATCH] dm-zoned: Fix overflow in exposed capacity Damien Le Moal
2017-06-09 12:03 ` Mike Snitzer
2017-06-09 14:41   ` Damien Le Moal
2017-06-12 21:28   ` rebased dm-zoned changes on jens/for-4.13/block [was: Re: dm-zoned: Fix overflow in exposed capacity] Mike Snitzer
2017-06-13 23:30     ` Damien Le Moal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.