Skip to content

Commit

Permalink
dm stripe: avoid divide by zero with invalid stripe count
Browse files Browse the repository at this point in the history
If a table containing zero as stripe count is passed into stripe_ctr
the code attempts to divide by zero.

This patch changes DM_TABLE_LOAD to return -EINVAL if the stripe count
is zero.

We now get the following error messages:
  device-mapper: table: 253:0: striped: Invalid stripe count
  device-mapper: ioctl: error adding target to table

Signed-off-by: Nikanth Karthikesan <knikanth@suse.de>
Cc: stable@kernel.org
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
  • Loading branch information
Nikanth Karthikesan authored and Alasdair G Kergon committed Feb 16, 2010
1 parent 0813e22 commit 781248c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/md/dm-stripe.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
}

stripes = simple_strtoul(argv[0], &end, 10);
if (*end) {
if (!stripes || *end) {
ti->error = "Invalid stripe count";
return -EINVAL;
}
Expand Down

0 comments on commit 781248c

Please sign in to comment.