diff --git a/libuavcan_drivers/posix/include/uavcan_posix/file_server_backend.hpp b/libuavcan_drivers/posix/include/uavcan_posix/file_server_backend.hpp index 963982bb23..d6280e6bc3 100644 --- a/libuavcan_drivers/posix/include/uavcan_posix/file_server_backend.hpp +++ b/libuavcan_drivers/posix/include/uavcan_posix/file_server_backend.hpp @@ -78,7 +78,7 @@ public: len = ::read(fd, bytes, MaxBufferLength); if (len < 0) { - return rv; + goto out_close; } if (len > 0) { @@ -87,7 +87,6 @@ public: } } while(len); - close(fd); out_crc64 = crc.get(); out_size = size; EntryType t; @@ -95,6 +94,9 @@ public: out_type = t; rv = 0; } + +out_close: + close(fd); } return rv; }