diff mbox series

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

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

Commit Message

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

Found with the SVACE static analysis tool.
---
 src/gatt-database.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/src/gatt-database.c b/src/gatt-database.c
index 5756eb9d1..8472aac59 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -2598,6 +2598,11 @@  static bool sock_io_read(struct io *io, void *user_data)
 	int fd = io_get_fd(io);
 	ssize_t bytes_read;
 
+	if (fd < 0) {
+		error("io_get_fd() returned %d\n", fd);
+		return false;
+	}
+
 	bytes_read = read(fd, buf, sizeof(buf));
 	if (bytes_read <= 0)
 		return false;