corelib/counter: Fix ck_malloc wrapper functions.

Return NULL on allocation failure and do not ignore
deferral flag. This avoids unnecessary deferrals if
possible.
corelib/counter: Correctly handle NULL case.