[PATCH BlueZ v1] core/gatt: add return value check of io_get_fd() to sock_read()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It is necessary to add a return value check.

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

diff --git a/src/gatt-client.c b/src/gatt-client.c
index 60a21e3f6..8d83a9577 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -1127,6 +1127,11 @@ static bool sock_read(struct io *io, void *user_data)
 	msg.msg_iov = &iov;
 	msg.msg_iovlen = 1;
 
+	if (fd < 0) {
+		error("io_get_fd() returned %d\n", fd);
+		return false;
+	}
+
 	bytes_read = recvmsg(fd, &msg, MSG_DONTWAIT);
 	if (bytes_read < 0) {
 		error("recvmsg: %s", strerror(errno));
-- 
2.34.1





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux