[4/5] telemetry: fix checking error return for socket creation

Message ID 20200512152902.70211-5-ciara.power@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series small fixes for telemetry rework. |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Power, Ciara May 12, 2020, 3:29 p.m. UTC
  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")
Cc: ciara.power@intel.com

Signed-off-by: Ciara Power <ciara.power@intel.com>
---
 lib/librte_telemetry/telemetry_legacy.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Kevin Laatz May 18, 2020, 2:53 p.m. UTC | #1
On 12/05/2020 16:29, Ciara Power wrote:
> 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")
> Cc: ciara.power@intel.com
>
> Signed-off-by: Ciara Power <ciara.power@intel.com>
> ---
>   lib/librte_telemetry/telemetry_legacy.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
Acked-by: Kevin Laatz <kevin.laatz@intel.com>
  

Patch

diff --git a/lib/librte_telemetry/telemetry_legacy.c b/lib/librte_telemetry/telemetry_legacy.c
index 72471cbfbe..2de9021349 100644
--- a/lib/librte_telemetry/telemetry_legacy.c
+++ b/lib/librte_telemetry/telemetry_legacy.c
@@ -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));