diff mbox series

[BlueZ,v3,resend,1/6] gatt: add a check to sock_io_send()

Message ID 20240710141621.64394-2-r.smirnov@omp.ru (mailing list archive)
State Accepted
Commit e56fc72fc66765f407473e4cb903fdc80784a4ff
Headers show
Series fix errors found by SVACE static analyzer #1 | expand

Commit Message

Roman Smirnov July 10, 2024, 2:16 p.m. UTC
It is necessary to add a return value check.

Found with the SVACE static analysis tool.
---
 V1 -> V3: the patch name has been shortened
 src/gatt-database.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/gatt-database.c b/src/gatt-database.c
index 8472aac59..6c84b085c 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -2630,6 +2630,7 @@  static int sock_io_send(struct io *io, const void *data, size_t len)
 {
 	struct msghdr msg;
 	struct iovec iov;
+	int fd;
 
 	iov.iov_base = (void *) data;
 	iov.iov_len = len;
@@ -2638,7 +2639,13 @@  static int sock_io_send(struct io *io, const void *data, size_t len)
 	msg.msg_iov = &iov;
 	msg.msg_iovlen = 1;
 
-	return sendmsg(io_get_fd(io), &msg, MSG_NOSIGNAL);
+	fd = io_get_fd(io);
+	if (fd < 0) {
+		error("io_get_fd() returned %d\n", fd);
+		return fd;
+	}
+
+	return sendmsg(fd, &msg, MSG_NOSIGNAL);
 }
 
 static void att_disconnect_cb(int err, void *user_data)