Commit 7ea065d6 authored by Helen Koike's avatar Helen Koike Committed by Greg Kroah-Hartman

dm init: fix max devices/targets checks

commit 8e890c1a upstream.

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: 6bbc923d ("dm: add support to directly boot to a mapped device")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarHelen Koike <helen.koike@collabora.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 29374659
...@@ -160,7 +160,7 @@ static int __init dm_parse_table(struct dm_device *dev, char *str) ...@@ -160,7 +160,7 @@ static int __init dm_parse_table(struct dm_device *dev, char *str)
while (table_entry) { while (table_entry) {
DMDEBUG("parsing table \"%s\"", str); 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", DMERR("too many targets %u > %d",
dev->dmi.target_count, DM_MAX_TARGETS); dev->dmi.target_count, DM_MAX_TARGETS);
return -EINVAL; return -EINVAL;
...@@ -242,9 +242,9 @@ static int __init dm_parse_devices(struct list_head *devices, char *str) ...@@ -242,9 +242,9 @@ static int __init dm_parse_devices(struct list_head *devices, char *str)
return -ENOMEM; return -ENOMEM;
list_add_tail(&dev->list, devices); list_add_tail(&dev->list, devices);
if (++ndev >= DM_MAX_DEVICES) { if (++ndev > DM_MAX_DEVICES) {
DMERR("too many targets %u > %d", DMERR("too many devices %lu > %d",
dev->dmi.target_count, DM_MAX_TARGETS); ndev, DM_MAX_DEVICES);
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment