test/telemetry: fix socket resource leak
If an error occurred when reading from the socket, the function
returned without closing the socket. This is now fixed to avoid the
resource leak of the sock variable going out of scope.
Coverity issue: 363043
Fixes: bd78cf693e
("test/telemetry: add unit tests for data to JSON")
Signed-off-by: Ciara Power <ciara.power@intel.com>
Acked-by: Kevin Laatz <kevin.laatz@intel.com>
This commit is contained in:
parent
8b4a23f115
commit
89ce9f09e2
@ -330,6 +330,7 @@ connect_to_socket(void)
|
||||
if (bytes < 0) {
|
||||
printf("%s: Error with socket read - %s\n", __func__,
|
||||
strerror(errno));
|
||||
close(sock);
|
||||
return -1;
|
||||
}
|
||||
buf[bytes] = '\0';
|
||||
|
Loading…
Reference in New Issue
Block a user