From patchwork Mon Aug 20 16:00:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Genoud X-Patchwork-Id: 178866 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E0ED62C00B0 for ; Tue, 21 Aug 2012 02:02:16 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T3UPF-00072S-Rl; Mon, 20 Aug 2012 16:00:45 +0000 Received: from mail-we0-f177.google.com ([74.125.82.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1T3UP3-0006xH-Na for linux-mtd@lists.infradead.org; Mon, 20 Aug 2012 16:00:34 +0000 Received: by mail-we0-f177.google.com with SMTP id r3so4351481wey.36 for ; Mon, 20 Aug 2012 09:00:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=iKiTmPFgVft86B4y/1tUF5vMDLj9C2By52nMeuIv5G0=; b=XexSbo1UAGZJDxltzy2j4otqQ19Ue0t3IV8PbMO/X5PTxRItvEIi0a4Ea0un70tpxU wezXGk40euBVs59kAw1UQtX2iwvsQ+j40RX4ICRL7kUU+Ulslr42d+BykGd5E7xm6XKU VbMFMs6KeW27juSgdwNcBl7pekw/nwAnBNVuGqrtQh8KU7AY7IzN7wJBLMPfH3z4RCXH 5ZkJJ5Cvqrx+yWhwG+FhdPGiv8w2ZKxbhEWyejHzU3zUv+cWJrvkVTjgz1x3IYZ43wJ9 +rDAPIuYk2mqXaJfcjAUaeYdVNxQg1gvtgHxQo+oDYZi822Kw4RKXyo12jfTOW+pP5cL APXw== Received: by 10.180.98.138 with SMTP id ei10mr30351831wib.1.1345478433309; Mon, 20 Aug 2012 09:00:33 -0700 (PDT) Received: from localhost.localdomain (lyon.paratronic.fr. [213.41.177.106]) by mx.google.com with ESMTPS id ef5sm42489198wib.3.2012.08.20.09.00.31 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 20 Aug 2012 09:00:32 -0700 (PDT) From: Richard Genoud To: Artem Bityutskiy Subject: [PATCH v3 3/6] UBI: check max_beb_per1024 value in ubi_attach_mtd_dev Date: Mon, 20 Aug 2012 18:00:13 +0200 Message-Id: <1345478416-23900-4-git-send-email-richard.genoud@gmail.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1345478416-23900-1-git-send-email-richard.genoud@gmail.com> References: <1345478416-23900-1-git-send-email-richard.genoud@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (richard.genoud[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Richard Genoud , linux-mtd@lists.infradead.org, Shmulik Ladkani X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org max_beb_per1024 shouldn't be negative, and a 0 value will be treated as the default value. For the upper bound, 768/1024 should be enough. Signed-off-by: Richard Genoud --- drivers/mtd/ubi/build.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 3c0b91f..6a749d6 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -49,6 +49,9 @@ /* Maximum number of comma-separated items in the 'mtd=' parameter */ #define MTD_PARAM_MAX_COUNT 2 +/* Maximum value for the number of bad eraseblocks per 1024 limit */ +#define MAX_MTD_UBI_BEB_LIMIT 768 + #ifdef CONFIG_MTD_UBI_MODULE #define ubi_is_module() 1 #else @@ -855,6 +858,15 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, struct ubi_device *ubi; int i, err, ref = 0; + if ((max_beb_per1024 < 0) || (max_beb_per1024 > MAX_MTD_UBI_BEB_LIMIT)) + return -EINVAL; + + /* + * Use the default value if max_beb_per1024 isn't provided. + */ + if (!max_beb_per1024) + max_beb_per1024 = CONFIG_MTD_UBI_BEB_LIMIT; + /* * Check if we already have the same MTD device attached. *