From: Jonthan Brassow Date: Tue, 9 Aug 2011 23:13:33 +0000 (+1000) Subject: Fix off-by-one error in validation of write_mostly. X-Git-Tag: next-20110810~29^2~8 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=a16a20ae2e99e4e2f53e8f3383b4626ac3a2db8d;p=karo-tx-linux.git Fix off-by-one error in validation of write_mostly. The user-supplied value given for the 'write_mostly' argument must be an index starting at 0. The validation of the supplied argument failed to check for 'N' ('>' vs '>='), which would have caused an access beyond the end of the array. Reported-by: Doug Ledford Signed-off-by: Jonathan Brassow Signed-off-by: Alasdair G Kergon --- diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index a002dd85db1e..86df8b2cf927 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c @@ -449,7 +449,7 @@ static int parse_raid_params(struct raid_set *rs, char **argv, rs->ti->error = "write_mostly option is only valid for RAID1"; return -EINVAL; } - if (value > rs->md.raid_disks) { + if (value >= rs->md.raid_disks) { rs->ti->error = "Invalid write_mostly drive index given"; return -EINVAL; }