cortex_m: add missing error checking