Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2891645pxb; Tue, 24 Aug 2021 10:00:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7pVwveJ1to+68pVu6Etwpkr2Qo/1aVGFpwtddOV3ArQ1aeGx2qrallBZn6g7XcNg3zrhS X-Received: by 2002:a17:906:491a:: with SMTP id b26mr42206873ejq.25.1629824408305; Tue, 24 Aug 2021 10:00:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629824408; cv=none; d=google.com; s=arc-20160816; b=SPrKwepMG9FKM1ySgosLenG4wNEL3MwAk4LLE6cBGhoAx1PO9ho9ljTgbSS7VWW3FO Rf6Kw/hAnGaPwHPGdVTJ0FSTx4YoA1B8RmOcNsLV9chuQmEDx8BaZizL/JSOCsTFjlSY SHoMgc/aetho0HY5PqgGYU2+vw/fDCXCMSFdsjzlxlp9W++PCUxc5UlPMhLl2PGw/Q4G xfRVa+vNYcVSpy2hNaUJoIQjkGIox0AcYQPpZGFqZtPh7yPplM8i/4k0HkFOGBjBGpkj M+qEKYSi7GlDeAHJ809FS9u/20F6+sEOOvoxT8zTttX5u5cYUNbUc2y/JhIc93A6vZ9c IhOw== 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=A+mzR//hGHNQKwhfnmZaHT9uwY2irEOXwNZ/kFOjdP4=; b=EjQtDQEG1xiHtNwhCAdZGFcnJ9o+r6GdmQUlI8fOcD1SJMYaxKzWcmUHyLmt69CnZG TQHWmIlubpEKpgqJEKYOcjDKrGCLcy+J9IqD42xCqbLEGIhAady9NZbiEXIgIpZq7jrk JJKaztRgLdR8gxK2daPq9xxdRgSbLlE9mtgfXo7G6HptRip4FPSSpnBxNB7F2iKCNS2P 6d8ByFgal/Y1roYa37iijK6F3OVcfF+u0YsK/LHLWax0DcprKL99EMU/umRNpSRR9elv B+SjGFnwiHH3ZhxDE9iL6GQxHNWLPRJ+DhontkXZOPEa1RzMqO9YzaK4DCkF/FaNrTt9 kyOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qcXnM5DO; 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 qw28si4798789ejc.608.2021.08.24.09.59.44; Tue, 24 Aug 2021 10:00:08 -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=qcXnM5DO; 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 S233729AbhHXQ6V (ORCPT + 99 others); Tue, 24 Aug 2021 12:58:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:39332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234514AbhHXQ5S (ORCPT ); Tue, 24 Aug 2021 12:57:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E11BF6140A; Tue, 24 Aug 2021 16:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824194; bh=zWITycdEmnFZK2EjMLbdmEPHankEIC+qDAKgQrLWXQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qcXnM5DOSsUAu+xfW+k9YMgp/2Eerv05G2IHJgzmTORtibLmNiPrpIJtFx1o4otS0 HbEkRP0hGmoslO/oHmxwkwiKx3fIAa/3dOd81rS3fa0N5ETctw0CP646mM8HFt6eHw V9V5zX8mD52Z2P9BAxBV8djDcU6EYEVl5Rgs0fd3pdcXgJ0Tx558hcnQ0dOrXbSlyU y/rWahaD+abo2oBhgYWLS49UYW3cKo+y17ZyEk4hcQr40+Hd9ns6TjH8J4r67n/chI uhNw6X5cRlIrUwLlXu30BtLy3S4QMq6Z9nyDmTzatlpb//yu8ZuwYHyEshu3hsK4aI T+JYMyEqgge/g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dan Carpenter , Manivannan Sadhasivam , Miquel Raynal , Sasha Levin Subject: [PATCH 5.13 026/127] mtd: rawnand: Add a check in of_get_nand_secure_regions() Date: Tue, 24 Aug 2021 12:54:26 -0400 Message-Id: <20210824165607.709387-27-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: Dan Carpenter [ Upstream commit 14f97f0b8e2b9950c028d0cb7311ffe26a3cc1c0 ] Check for whether of_property_count_elems_of_size() returns a negative error code. Fixes: 13b89768275d ("mtd: rawnand: Add support for secure regions in NAND memory") Signed-off-by: Dan Carpenter Reviewed-by: Manivannan Sadhasivam Signed-off-by: Miquel Raynal Link: https://lore.kernel.org/linux-mtd/YMtQFXE0F1w7mUh+@mwanda Signed-off-by: Sasha Levin --- drivers/mtd/nand/raw/nand_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index fb072c444495..b18c089a7dca 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -5059,8 +5059,8 @@ static int of_get_nand_secure_regions(struct nand_chip *chip) int nr_elem, i, j; nr_elem = of_property_count_elems_of_size(dn, "secure-regions", sizeof(u64)); - if (!nr_elem) - return 0; + if (nr_elem <= 0) + return nr_elem; chip->nr_secure_regions = nr_elem / 2; chip->secure_regions = kcalloc(chip->nr_secure_regions, sizeof(*chip->secure_regions), -- 2.30.2