firmware-utils/mkchkimg: fix possible resource leaks