Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1050115yba; Fri, 26 Apr 2019 13:11:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6CMSTQnRnEBatWLfjnWwnJjvaOe96e4lYPO5PfTaQqUzMoTA8XCzsrU5VC8k0OVjVTfoN X-Received: by 2002:a17:902:bcc6:: with SMTP id o6mr42504577pls.275.1556309483662; Fri, 26 Apr 2019 13:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556309483; cv=none; d=google.com; s=arc-20160816; b=Qe8dQwOsgOaZ6f5cBVsT+h4WHxXzN7zKlcrxCZhOHAr2z7NbhFEm5t+HrP6hWsmnKo wJiEv/tNHK44hKAg6RUFKwgYdb/TESV6wbU2GyRWY9V8xmasqYjoTt6u45SvFJEemljN lzgvraGKmyT00z/WBoelioLGsxizLMlL1v5VCxvUfkvezF+F/Iw4k7qTvGGCLNcMz2fe +Z48oRuIX4GV2AKR7QkwU0tydqKI3XVXRVlbwVAaL5LFJk5+P6/rP/XRBn1O7u3HoZc5 R/Tl1foIl7jdjewIymxr03/8tTdRBmfmSvKi0RNmmTIpDp/5XDgQs8uAIzOMmVBMnejO lSOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=eNgZxVkXxyWgiJiLF9SL7jAKCOqYEdvFetIXiIQyl90=; b=Yd7i4KdZktsKhNke2325y0CPDESmUl0gDm04o+1bPI3xhoWE4Hfl+fcxRFirC4VDF0 jPFKwqS4w22bmFURvkmEYoi4c+Hf8dR3dJlpQRpcpnl03mtYHhGufhXSNxMYRVslUqYV OyJ2bW91B1jJiIuVf2Ij/cuk6ygOo0gy9f+ENjdKDHGZHoezYY+RGmCZ5UlKhMOoF+s+ gFswzE14ZUcnZltKuxNZeGzEHtbJtkaFJuRkxJA82Td7yJtG0Jc8mMhINlBN7hZhc6tv pG7utH9CY2T1JOXA5DqiwHsP1MrNmaVuTlydP2WLmRed7mUvHf653vYGeb3XzIS+341j Sw1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h63si24918244pgc.404.2019.04.26.13.11.07; Fri, 26 Apr 2019 13:11:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726766AbfDZUKK (ORCPT + 99 others); Fri, 26 Apr 2019 16:10:10 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:40812 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726083AbfDZUKK (ORCPT ); Fri, 26 Apr 2019 16:10:10 -0400 Received: from localhost.localdomain (unknown [IPv6:2804:431:9718:9080:8461:642a:3a75:dbc6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: koike) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 971D426C476; Fri, 26 Apr 2019 21:10:06 +0100 (BST) From: Helen Koike To: dm-devel@redhat.com Cc: kernel@collabora.com, Helen Koike , Mike Snitzer , linux-kernel@vger.kernel.org, Alasdair Kergon Subject: [PATCH] dm: init: fix max devices/targets checks Date: Fri, 26 Apr 2019 17:09:55 -0300 Message-Id: <20190426200955.17886-1-helen.koike@collabora.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Helen Koike --- Hi, This patch was tested by manipulating DM_MAX_TARGETS and DM_MAX_DEVICES macros and making sure the test cases in the following test script[1] was passing or failing when they should. [1] https://gitlab.collabora.com/koike/dm-cmdline-test Thanks Helen drivers/md/dm-init.c | 8 ++++---- 1 file 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; } -- 2.20.1