kernel: delayed_work: fix race condition in k_delayed_work_cancel

The implementation checks the work queue pointer before taking a lock
and entering code that, depending on build options, may fault if that
pointer is null.  Move the check under the lock to ensure condition is
preserved.  Then the check in work_cancel is no longer necessary since
condition is verified under lock at all call sites.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
1 file changed