Free allocated memory in error path

Signed-off-by: Michal Čihař <michal@cihar.com>
Avoid resource leak on failed read

Signed-off-by: Michal Čihař <michal@cihar.com>