Skip to content

Commit

Permalink
dm init: fix max devices/targets checks
Browse files Browse the repository at this point in the history
dm-init should allow up to DM_MAX_{DEVICES,TARGETS} for devices/targets,
and not DM_MAX_{DEVICES,TARGETS} - 1.

Fix the checks and also fix the error message when the number of devices
is surpassed.

Fixes: 6bbc923 ("dm: add support to directly boot to a mapped device")
Cc: stable@vger.kernel.org
Signed-off-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
  • Loading branch information
Helen Koike authored and snitm committed Apr 30, 2019
1 parent e4f3fab commit 8e890c1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/md/dm-init.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static int __init dm_parse_table(struct dm_device *dev, char *str)

while (table_entry) {
DMDEBUG("parsing table \"%s\"", str);
if (++dev->dmi.target_count >= DM_MAX_TARGETS) {
if (++dev->dmi.target_count > DM_MAX_TARGETS) {
DMERR("too many targets %u > %d",
dev->dmi.target_count, DM_MAX_TARGETS);
return -EINVAL;
Expand Down Expand Up @@ -242,9 +242,9 @@ static int __init dm_parse_devices(struct list_head *devices, char *str)
return -ENOMEM;
list_add_tail(&dev->list, devices);

if (++ndev >= DM_MAX_DEVICES) {
DMERR("too many targets %u > %d",
dev->dmi.target_count, DM_MAX_TARGETS);
if (++ndev > DM_MAX_DEVICES) {
DMERR("too many devices %lu > %d",
ndev, DM_MAX_DEVICES);
return -EINVAL;
}

Expand Down

0 comments on commit 8e890c1

Please sign in to comment.