diff mbox series

[BlueZ,v1] gatt: add return value check of io_get_fd() to sock_io_send()

Message ID 20240702134106.102024-1-r.smirnov@omp.ru
State New
Headers show
Series [BlueZ,v1] gatt: add return value check of io_get_fd() to sock_io_send() | expand

Commit Message

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

Found with the SVACE static analysis tool.
---
 src/gatt-database.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Comments

patchwork-bot+bluetooth@kernel.org July 10, 2024, 2:30 p.m. UTC | #1
Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Tue, 2 Jul 2024 16:41:06 +0300 you wrote:
> It is necessary to add a return value check.
> 
> Found with the SVACE static analysis tool.
> ---
>  src/gatt-database.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

Here is the summary with links:
  - [BlueZ,v1] gatt: add return value check of io_get_fd() to sock_io_send()
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=e56fc72fc667

You are awesome, thank you!
diff mbox series

Patch

diff --git a/src/gatt-database.c b/src/gatt-database.c
index 5756eb9d1..99aa6b63a 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -2625,6 +2625,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;
@@ -2633,7 +2634,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)