telemetry: check socket creation failure
authorCiara Power <ciara.power@intel.com>
Tue, 12 May 2020 15:29:01 +0000 (16:29 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 19 May 2020 13:05:56 +0000 (15:05 +0200)
The return value from the socket function is now checked, as it can
return a negative value on error.

Coverity issue: 358443
Fixes: b80fe1805eee ("telemetry: introduce backward compatibility")

Signed-off-by: Ciara Power <ciara.power@intel.com>
Acked-by: Kevin Laatz <kevin.laatz@intel.com>
lib/librte_telemetry/telemetry_legacy.c

index 72471cb..2de9021 100644 (file)
@@ -95,6 +95,10 @@ register_client(const char *cmd __rte_unused, const char *params,
        *strchr(data, '\"') = 0;
 
        fd = socket(AF_UNIX, SOCK_SEQPACKET, 0);
+       if (fd < 0) {
+               perror("Failed to open socket");
+               return -1;
+       }
        addrs.sun_family = AF_UNIX;
        strlcpy(addrs.sun_path, data, sizeof(addrs.sun_path));