Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2892305pxb; Tue, 24 Aug 2021 10:00:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK54CRoL8Qdp3/nFNSlu6ZsTcJXEggpnAOUFUB/BJ5gthNnSUSUKs9uNq+9OuDHu3Tr7sk X-Received: by 2002:a17:907:94c6:: with SMTP id dn6mr43388726ejc.287.1629824456962; Tue, 24 Aug 2021 10:00:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629824456; cv=none; d=google.com; s=arc-20160816; b=Og96hxnADD38Pr6av6x2DVe0t4uUsd5DssjmdkLpIuMAUvrOIKSMfXP8zTsyMUJFpr YncQH2gSB+8KpMxYZzJ3S1DxEhbkvqe5/+r0ccYyy7HT3BUsxzSN5SEwR5YashEHgus2 GVeyKDjtaGTNbZH9GbKdMS7fdIBKffLP+FdwI0agy5zyHwGXyB4s1PpEpaRgZN6HaBBt mTdUWfPzGKpR4aDjT1PZh4qJI+E5JvB45xxUpMZzF6EuCA4vLZhRZXEaM5SWyn9SknZa wIQp80uOCtG5aLFG8Pk5ZQtYhkqJvjyou52QLzvBDMfOPVg9Ffn7IwFcDUOI9B9x/iL7 XzMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yYntqMgSwz72bWS3mOzA4eBOWU1wwzDBqjAmQ74cVfk=; b=Pc5aLsleqVPCP5ps9Dn2ucOyP2VxGEcWgoTRKSJhqwQibS4cgOUFGuzM5xBpbjcFCL voMwg+qM0uQAAiRACsfNRZbTKk+o900+XQu2XcneYHu2QRycXhOWX4XKmdXTBVmiK/8y F91KjdoWJdj/dC31Kqy33vGIREXo89g8ke2m4VL9zYCK67kGFZa1S0s5DticNDtp1oFK ROpE9axk1OaMbst/IrZRHhJK75vvLubAVZYkBd7jSR3/9ppFQ2I+SCMA0WDy1Mb07GX6 8wsLUz0yFYW813wWzOnxK0OMHFbOh0bNKsLL8xcmw/MVZZvI/YnoBrKIoWHkVN0ShAP5 Obng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gurek7Ld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n15si10784444edy.328.2021.08.24.10.00.33; Tue, 24 Aug 2021 10:00:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Gurek7Ld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238653AbhHXQ6j (ORCPT + 99 others); Tue, 24 Aug 2021 12:58:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:39542 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234194AbhHXQ51 (ORCPT ); Tue, 24 Aug 2021 12:57:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0F022613B1; Tue, 24 Aug 2021 16:56:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824202; bh=5GkxJ/uysXH+AciU0UQE3ODT8MTstUCYeJtqNtYgWDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gurek7LdcDSDTk0usj50BZzqpepgNlDm02vkekTF0+lExaYKuVsWMK3CXla7jVsC1 q/wNLEGYgFo2N92+kSICnmv9I0DkhaB9t7w9igDG1u9+hWChIAjGZDOZ8MEh5sHUsY cjOHiSzvuThl7ZMoC9HJHhVanukQdcHtZOZEnanYtiPc5JOQuhAndNtDlxCa/6VwFF x5xpQB8/AL5O6W6sVhtKqdbL+It57oZAj0oVjDZT0wGZRswo/bw4mCGOHcThkwiJG9 HCdr74ozvoo9IoANUlfqt3NnWtY20h5LtzyqnEnX6ai6Z3VnEyaYgMHtRspWL7sM/s RNhEufMcoT5zg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Manivannan Sadhasivam , Martin Kaiser , Miquel Raynal , Sasha Levin Subject: [PATCH 5.13 035/127] mtd: rawnand: Fix probe failure due to of_get_nand_secure_regions() Date: Tue, 24 Aug 2021 12:54:35 -0400 Message-Id: <20210824165607.709387-36-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824165607.709387-1-sashal@kernel.org> References: <20210824165607.709387-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.13.13-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.13.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.13.13-rc1 X-KernelTest-Deadline: 2021-08-26T16:55+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Manivannan Sadhasivam [ Upstream commit b48027083a78b13356695555a05b0e085e378687 ] Due to 14f97f0b8e2b, the rawnand platforms without "secure-regions" property defined in DT fails to probe. The issue is, of_get_nand_secure_regions() errors out if of_property_count_elems_of_size() returns a negative error code. If the "secure-regions" property is not present in DT, then also we'll get -EINVAL from of_property_count_elems_of_size() but it should not be treated as an error for platforms not declaring "secure-regions" in DT. So fix this behaviour by checking for the existence of that property in DT and return 0 if it is not present. Fixes: 14f97f0b8e2b ("mtd: rawnand: Add a check in of_get_nand_secure_regions()") Reported-by: Martin Kaiser Signed-off-by: Manivannan Sadhasivam Reviewed-by: Martin Kaiser Tested-by: Martin Kaiser Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/20210727062813.32619-1-manivannan.sadhasivam@linaro.org Signed-off-by: Sasha Levin --- drivers/mtd/nand/raw/nand_base.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index b18c089a7dca..4412fdc240a2 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -5056,8 +5056,14 @@ static bool of_get_nand_on_flash_bbt(struct device_node *np) static int of_get_nand_secure_regions(struct nand_chip *chip) { struct device_node *dn = nand_get_flash_node(chip); + struct property *prop; int nr_elem, i, j; + /* Only proceed if the "secure-regions" property is present in DT */ + prop = of_find_property(dn, "secure-regions", NULL); + if (!prop) + return 0; + nr_elem = of_property_count_elems_of_size(dn, "secure-regions", sizeof(u64)); if (nr_elem <= 0) return nr_elem; -- 2.30.2