Is it safe to boot computer that lost power while suspending to disk?
If power is lost prior to explicitly entering S4 or S5 state (hereafter just referred to as "hibernation state" for simplicity), then the partially filled data in the swap partition will be ignored completely, because there's no hibernation state persisted. Swap partitions and files are also volatile, and the data in it will be ignored after a reboot without hibernation state.
In the kernel, restoration from hibernation is requested by the configured platform_hibernation_ops->leave
, which is only called on resumption from hibernation state. For example, on most modern platforms where S5 is supported, we configure a reboot notifier.
Losing power prior to hibernation state being entered (and thus the hibernation file being completely written) won't have configured any hibernation to resume from, so there's no chance it will try to thaw using the partially-filled swap space. As such, you don't have to worry about the kernel trying to restore from a partially complete hibernation.