diff mbox series

[BlueZ,v2,resend,3/6] client/player: add error code handling to transport_recv()

Message ID 20240710113151.49296-4-r.smirnov@omp.ru (mailing list archive)
State Superseded
Commit 12525371ef082483d524447310da7d0f5866bf91
Headers show
Series fix errors found by SVACE static analyzer #1 | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Roman Smirnov July 10, 2024, 11:31 a.m. UTC
It is necessary to add return value check as in sock_send().

Found with the SVACE static analysis tool.
---
 client/player.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/client/player.c b/client/player.c
index 584fc5e81..de4491b53 100644
--- a/client/player.c
+++ b/client/player.c
@@ -4514,7 +4514,13 @@  static bool transport_recv(struct io *io, void *user_data)
 	uint8_t buf[1024];
 	int ret, len;
 
-	ret = read(io_get_fd(io), buf, sizeof(buf));
+	ret = io_get_fd(io);
+	if (ret < 0) {
+		bt_shell_printf("io_get_fd() returned %d\n", ret);
+		return true;
+	}
+
+	ret = read(ret, buf, sizeof(buf));
 	if (ret < 0) {
 		bt_shell_printf("Failed to read: %s (%d)\n", strerror(errno),
 								-errno);