fix crash when inlining casts of erroneous expressions

Sparse do inlining very early, during expansion, just after (type)
evaluation and before IR linearization, and is done even if some
errors have been found. This means that the inlining must be robust
against erroneous code.

However, during inlining, a cast expression is always dereferenced and
a crash will occur if not valid (in which case it should be null).

Fix this by checking for null cast expressions and directly returning
NULL, like done for the inlining of the other invalid expressions.

Reported-by: kernel test robot <>
Reported-by: Yafang Shao <>
Reported-by: Yujie Liu <>
Signed-off-by: Luc Van Oostenryck <>
2 files changed