From 21a4b0e8092aae5a55d9ca20ecb54876dca13ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20G=C5=82=C4=85bek?= Date: Wed, 3 Feb 2021 13:53:48 +0100 Subject: [PATCH] scripts: kconfig: Fix uses of edt.compat2okay in helper functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check if a given 'compat' is a key in edt.compat2okay before accessing its entry in dt_compat_on_bus() and dt_nodelabel_has_compat(), as for a non-existing key a new entry with an empty list would be created, and dt_compat_enabled() would then incorrectly return "y" when called for the same 'compat'. Signed-off-by: Andrzej Głąbek --- scripts/kconfig/kconfigfunctions.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/kconfig/kconfigfunctions.py b/scripts/kconfig/kconfigfunctions.py index e4d5739cb2f072..e2eb0d13d24c69 100644 --- a/scripts/kconfig/kconfigfunctions.py +++ b/scripts/kconfig/kconfigfunctions.py @@ -390,9 +390,10 @@ def dt_compat_on_bus(kconf, _, compat, bus): if doc_mode or edt is None: return "n" - for node in edt.compat2okay[compat]: - if node.on_bus is not None and node.on_bus == bus: - return "y" + if compat in edt.compat2okay: + for node in edt.compat2okay[compat]: + if node.on_bus is not None and node.on_bus == bus: + return "y" return "n" @@ -406,9 +407,10 @@ def dt_nodelabel_has_compat(kconf, _, label, compat): if doc_mode or edt is None: return "n" - for node in edt.compat2okay[compat]: - if label in node.labels: - return "y" + if compat in edt.compat2okay: + for node in edt.compat2okay[compat]: + if label in node.labels: + return "y" return "n"