doc/examples: add missing return in error paths

Reported by covery Scan.
doc/examples: don't double-use the same buffer for numa alloc and asprintf

Found by Coverity Scan.