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.

Link: https://lore.kernel.org/r/e42698a9-494c-619f-ac16-8ffe2c87e04e@intel.com
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Yafang Shao <laoar.shao@gmail.com>
Reported-by: Yujie Liu <yujie.liu@intel.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2 files changed