mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bill Wendling <morbo@google.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: masahiroy@kernel.org, linux-kbuild@vger.kernel.org,
	rdunlap@infradead.org,  Bill Wendling <morbo@google.com>
Subject: [PATCH v4] kconfig: check for a NULL pointer before access
Date: Fri, 27 Jun 2025 00:42:43 +0000	[thread overview]
Message-ID: <20250627004243.19514-1-morbo@google.com> (raw)
In-Reply-To: <CAEzuVAdu3bDXUGgi4U-XY4dRmBxKaCA_OjKrvK-2ftOWWwVEYA@mail.gmail.com>

The call to 'prop_get_symbol' may return NULL in some cases. The if-then
statement accesses the returned value without cheecking 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: Randy Dunlap <rdunlap@infradead.org>
Cc: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
v4:
  - Fix issue with patch formatting.
  - Patch is sent from original email account.
v3:
  - Fix whitespace for real now.
  - Patch from another email account so that the whitespace is retained.
v2:
  - Fix whitespace
---
 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.50.0.727.gbf7dc18ff4-goog


      reply	other threads:[~2025-06-27  0:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-23  0:07 [PATCH] " 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         ` Bill Wendling [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250627004243.19514-1-morbo@google.com \
    --to=morbo@google.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®