doc/examples: add missing return in error paths

Reported by covery Scan.

(cherry picked from commit 2617a8a6fc23aa4a33b5c814f22ff9b97e00b31e)
doc/examples: don't double-use the same buffer for numa alloc and asprintf

Found by Coverity Scan.

(cherry picked from commit 3ee91512d90d6b90d48f4ab5423c5ccf0db989fb)