Fix error handling.

MFC after:	1 month
Coverity CID:	1249768
Sponsored by:	The FreeBSD Foundation