Skip to content

Commit 272a721

Browse files
tchebbmasahir0y
authored andcommitted
kconfig: don't crash on NULL expressions in expr_eq()
NULL expressions are taken to always be true, as implemented by the expr_is_yes() macro and by several other functions in expr.c. As such, they ought to be valid inputs to expr_eq(), which compares two expressions. Signed-off-by: Thomas Hebb <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent fd2ab2f commit 272a721

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

scripts/kconfig/expr.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,13 @@ static int expr_eq(struct expr *e1, struct expr *e2)
254254
{
255255
int res, old_count;
256256

257+
/*
258+
* A NULL expr is taken to be yes, but there's also a different way to
259+
* represent yes. expr_is_yes() checks for either representation.
260+
*/
261+
if (!e1 || !e2)
262+
return expr_is_yes(e1) && expr_is_yes(e2);
263+
257264
if (e1->type != e2->type)
258265
return 0;
259266
switch (e1->type) {

0 commit comments

Comments
 (0)