Before returning because of an memory allocation error, free the memory
already allocated to buf.
Found using clang's static analyzer - scan-build
Submitted by: Thomas Rix <trix@juniper.net>
Reviewed by: stevek
Approved by: sjg (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D9852