Added check to avoid crashes with combined kernel and data locking