linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kconfig: check for a NULL pointer before access
@ 2025-05-23  0:07 Bill Wendling
  2025-05-23  0:16 ` Randy Dunlap
  2025-05-23 22:55 ` [PATCH v2] " Bill Wendling
  0 siblings, 2 replies; 11+ messages in thread
From: Bill Wendling @ 2025-05-23  0:07 UTC (permalink / raw)
  To: Masahiro Yamada, Linux Kbuild mailing list, LKML

The call to 'prop_get_symbol' may return NULL in some cases. The if-then
statement accesses the returned value without checking if it's
non-NULL. After inlining, the compiler may treat the conditional as
'undefined behavior', which the compiler may take the opportunity to do
whatever it wants with the UB path. This patch simply adds a check to
ensure that 'def_sym' is non-NULL to avoid this behavior.

Signed-off-by: Bill Wendling <morbo@google.com>
---
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 scripts/kconfig/symbol.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index d57f8cbba291..9c5068225328 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -272,7 +272,7 @@ struct symbol *sym_choice_default(struct menu *choice)
  if (prop->visible.tri == no)
  continue;
  def_sym = prop_get_symbol(prop);
- if (def_sym->visible != no)
+ if (def_sym && def_sym->visible != no)
  return def_sym;
  }

-- 
2.49.0.1164.gab81da1b16-goog

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-06-27  0:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-23  0:07 [PATCH] kconfig: check for a NULL pointer before access Bill Wendling
2025-05-23  0:16 ` Randy Dunlap
2025-05-23 22:56   ` Bill Wendling
2025-05-23 23:47     ` Randy Dunlap
2025-05-24  0:35       ` Bill Wendling
2025-05-23 22:55 ` [PATCH v2] " Bill Wendling
2025-05-24  0:49   ` [PATCH v3] " Bill Wendling
2025-05-24  2:13     ` Randy Dunlap
2025-05-24 17:07     ` Masahiro Yamada
2025-05-26  8:08       ` Bill Wendling
2025-06-27  0:42         ` [PATCH v4] " Bill Wendling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).