Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BC04FC7EE23 for ; Thu, 1 Jun 2023 16:26:01 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2AFD78637B; Thu, 1 Jun 2023 18:24:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="dj6USN6U"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9B8F18632B; Thu, 1 Jun 2023 18:24:37 +0200 (CEST) Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 545F586335 for ; Thu, 1 Jun 2023 18:24:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd35.google.com with SMTP id ca18e2360f4ac-7748edd6c87so2799139f.0 for ; Thu, 01 Jun 2023 09:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685636671; x=1688228671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=goEH/fZPr0Sm++zDtXA4AusDcKh/CKRkKNnZKxzb21M=; b=dj6USN6U58XguJelEVQnS+Fo1HWSdpr6gHMYYmGC+Im8b8Xr9LTAKJgxSmEhadJeov AZuy/bc4CKiHffxMkI8Oyi6rcwjclMab5/NRfqiFaa/ogDMq6IJ9u6FI5sGq+LvioNn5 2ZFbHsqxic61Zp9SAdzJZGKXWrCYuzV85QkGY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685636671; x=1688228671; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=goEH/fZPr0Sm++zDtXA4AusDcKh/CKRkKNnZKxzb21M=; b=T0e7nfpZVs+DzKlUDwx/NQ4RSihocFWiHrwlDL4zr9a3i9hPYgvI6E33+1umZmwEo3 25ng4NxgTCn1ejHz1Pgcrx1gPyMLJDENQzNjeo9xF73xuJ+FnZzeZwzYltJs9jbXF/jw LgZIBHDqeefgUhkIzUfE+ON+ubRLlH6nlkyf/NkNdNjkFGtkjVtOFuRiomMxHDjanNpd MRvziy1EcNJCjD3Kp3T32IoONNNMy1vRwVe71gdaTz6ylWcXseIIkJahPbmCXb7h8dFf wGnjZEtgyMZxWL8NnWaaiKXgn97icw73g1xQ5MceEE4a9PF+b1iiJ3rueuwUTjEURNAe 3ZfA== X-Gm-Message-State: AC+VfDxiZYC3x/KeKEen4vONXryrzxAqCV73NXhuOI2RbEzKarawOa09 H7oSig2rQjqtBdCQQHtDg7qr8euqOgZHX19pNlk= X-Google-Smtp-Source: ACHHUZ66H2Ase0qMcZdlkwmvC4Xj4FGl2ok04dhKWWEXkkuA0fracTZORshQbkxGamLHyGXkyrEqvw== X-Received: by 2002:a92:d292:0:b0:325:da54:ae8b with SMTP id p18-20020a92d292000000b00325da54ae8bmr4833812ilp.9.1685636671507; Thu, 01 Jun 2023 09:24:31 -0700 (PDT) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id l1-20020a922901000000b0033a6e7ee4e3sm3862098ilg.1.2023.06.01.09.24.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 09:24:31 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Heinrich Schuchardt , Tom Rini , Simon Glass , Marek Vasut , Pavel Herrmann Subject: [PATCH 07/40] dm: core: Avoid registering an inaccessible tree Date: Thu, 1 Jun 2023 10:22:31 -0600 Message-ID: <20230601162404.220488-6-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.rc0.172.g3f132b7071-goog In-Reply-To: <20230601162404.220488-1-sjg@chromium.org> References: <20230601162404.220488-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean At present there are various restrictions on the use of livetree: - It is only available once the tree is unflattened, i.e. after relocation - It is designed to be used with the control FDT - It can (in principle) be used with other FDTs, but only if they are unflattened first; this is not supported Add a few checks to make sure that any tree that is created is actually valid. Otherwise it can be confusing when nodes and properties cannot actually be accessed. Signed-off-by: Simon Glass --- drivers/core/ofnode.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index ec574c446079..1d4ab5bb6f2f 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -60,6 +60,11 @@ static oftree oftree_ensure(void *fdt) return oftree_null(); } + if (of_live_active()) { + log_err("Cannot register a flattree when OF_LIVE is active\n"); + return oftree_null(); + } + /* register the new tree */ i = oftree_count++; oftree_list[i] = fdt; @@ -133,6 +138,10 @@ oftree oftree_from_fdt(void *fdt) if (CONFIG_IS_ENABLED(OFNODE_MULTI_TREE)) return oftree_ensure(fdt); +#ifdef OF_CHECKS + if (of_live_active()) + return oftree_null(); +#endif tree.fdt = fdt; return tree; -- 2.41.0.rc0.172.g3f132b7071-goog