KERNEL: if a kernel is invalid give an error!

(cherry picked from commit 5102dc330e1f65f752e72794d1355f710e43c160)