From patchwork Mon Mar 19 16:28:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinz Mauelshagen X-Patchwork-Id: 10293123 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4DA7C602BD for ; Mon, 19 Mar 2018 16:28:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CE8F28D99 for ; Mon, 19 Mar 2018 16:28:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3157C29121; Mon, 19 Mar 2018 16:28:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D5CC029137 for ; Mon, 19 Mar 2018 16:28:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0E02F8535D; Mon, 19 Mar 2018 16:28:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CA14318EE5; Mon, 19 Mar 2018 16:28:29 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 68E964CA9A; Mon, 19 Mar 2018 16:28:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2JGSSce030441 for ; Mon, 19 Mar 2018 12:28:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id F08C3215CDCA; Mon, 19 Mar 2018 16:28:27 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from o.ww.redhat.com (ovpn-116-20.ams2.redhat.com [10.36.116.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 51D122166BAE; Mon, 19 Mar 2018 16:28:27 +0000 (UTC) From: Heinz Mauelshagen To: heinzm@redhat.com, dm-devel@redhat.com, snitzer@redhat.com Date: Mon, 19 Mar 2018 17:28:26 +0100 Message-Id: <1468ea2ed50e3fa3194e61b6ff5057d9db323ab4.1521476841.git.heinzm@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH] dm raid: use __within_range() more in parse_raid_params() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 19 Mar 2018 16:28:30 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP parse_raid_params() doesn't use __with_rnage() to check argument values throughout. Add where appropriate. Signed-off-by: Heinz Mauelshagen --- drivers/md/dm-raid.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c index 7ffa1839b206..38c53632dfeb 100644 --- a/drivers/md/dm-raid.c +++ b/drivers/md/dm-raid.c @@ -1371,7 +1371,7 @@ static int parse_raid_params(struct raid_set *rs, struct dm_arg_set *as, * MD records this value in kB */ value /= 2; - if (value > COUNTER_MAX) { + if (!__within_range(value, 1, COUNTER_MAX)) { rs->ti->error = "Max write-behind limit out of range"; return -EINVAL; } @@ -1382,7 +1382,7 @@ static int parse_raid_params(struct raid_set *rs, struct dm_arg_set *as, rs->ti->error = "Only one daemon_sleep argument pair allowed"; return -EINVAL; } - if (!value || (value > MAX_SCHEDULE_TIMEOUT)) { + if (!__within_range(value, 1, MAX_SCHEDULE_TIMEOUT)) { rs->ti->error = "daemon sleep period out of range"; return -EINVAL; } @@ -1430,7 +1430,7 @@ static int parse_raid_params(struct raid_set *rs, struct dm_arg_set *as, rs->ti->error = "Only one min_recovery_rate argument pair allowed"; return -EINVAL; } - if (value > INT_MAX) { + if (!__within_range(value, 1, INT_MAX)) { rs->ti->error = "min_recovery_rate out of range"; return -EINVAL; } @@ -1440,7 +1440,7 @@ static int parse_raid_params(struct raid_set *rs, struct dm_arg_set *as, rs->ti->error = "Only one max_recovery_rate argument pair allowed"; return -EINVAL; } - if (value > INT_MAX) { + if (!__within_range(value, 1, INT_MAX)) { rs->ti->error = "max_recovery_rate out of range"; return -EINVAL; }