From: Milan Broz Date: Tue, 6 Jan 2009 03:05:02 +0000 (+0000) Subject: dm log: ensure log bitmap fits on log device X-Git-Tag: v2.6.29-rc1~492^2~11 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=ac1f0ac22c7be908fd33407273b9808bfaedada4;p=linux-2.6-omap-h63xx.git dm log: ensure log bitmap fits on log device Check that the log bitmap will fit within the log device. Signed-off-by: Milan Broz Signed-off-by: Alasdair G Kergon --- diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c index 40ed70df673..737961f275c 100644 --- a/drivers/md/dm-log.c +++ b/drivers/md/dm-log.c @@ -457,6 +457,14 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti, */ buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) + bitset_size, ti->limits.hardsect_size); + + if (buf_size > dev->bdev->bd_inode->i_size) { + DMWARN("log device %s too small: need %llu bytes", + dev->name, (unsigned long long)buf_size); + kfree(lc); + return -EINVAL; + } + lc->header_location.count = buf_size >> SECTOR_SHIFT; lc->io_req.mem.type = DM_IO_VMA;