summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorHelen Koike <helen.koike@collabora.com>2019-04-26 23:09:55 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-05-25 19:16:45 +0300
commit7ea065d60114380f2c04c5e301198144d0bee603 (patch)
tree4c8c6a547883fba46c046b7272a9acd7780906ab /drivers/md
parent29374659f6ca21dc227bd31ce262fb88d40d2bdb (diff)
downloadlinux-7ea065d60114380f2c04c5e301198144d0bee603.tar.xz
dm init: fix max devices/targets checks
commit 8e890c1ab1b1e0f765cd8da82c4dee011698a5e8 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: 6bbc923dfcf57d ("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-init.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/md/dm-init.c b/drivers/md/dm-init.c
index 4b76f84424c3..352e803f566e 100644
--- a/drivers/md/dm-init.c
+++ b/drivers/md/dm-init.c
@@ -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;
@@ -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;
}