summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Le Moal <damien.lemoal@wdc.com>2017-07-03 09:44:58 +0300
committerMike Snitzer <snitzer@redhat.com>2017-07-05 23:08:47 +0300
commit3908c9839b1077e677ef9e92d2bce7f224519c59 (patch)
tree4b385dcc6742ce62ba9aeb1bed662cda3993df91
parent4d49f1b4a1fcab16b6dd1c79ef14f2b6531d50a6 (diff)
downloadlinux-3908c9839b1077e677ef9e92d2bce7f224519c59.tar.xz
dm zoned: fix overflow when converting zone ID to sectors
A zone ID is a 32 bits unsigned int which can overflow when doing the bit shifts in dmz_start_sect(). With a 256 MB zone size drive, the overflow happens for a zone ID >= 8192. Fix this by casting the zone ID to a sector_t before doing the bit shift. While at it, similarly fix dmz_start_block(). Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r--drivers/md/dm-zoned-metadata.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
index 4618441cc412..884ff7c170a0 100644
--- a/drivers/md/dm-zoned-metadata.c
+++ b/drivers/md/dm-zoned-metadata.c
@@ -191,12 +191,12 @@ unsigned int dmz_id(struct dmz_metadata *zmd, struct dm_zone *zone)
sector_t dmz_start_sect(struct dmz_metadata *zmd, struct dm_zone *zone)
{
- return dmz_id(zmd, zone) << zmd->dev->zone_nr_sectors_shift;
+ return (sector_t)dmz_id(zmd, zone) << zmd->dev->zone_nr_sectors_shift;
}
sector_t dmz_start_block(struct dmz_metadata *zmd, struct dm_zone *zone)
{
- return dmz_id(zmd, zone) << zmd->dev->zone_nr_blocks_shift;
+ return (sector_t)dmz_id(zmd, zone) << zmd->dev->zone_nr_blocks_shift;
}
unsigned int dmz_nr_chunks(struct dmz_metadata *zmd)