All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v2] client/player: add error code handling to transport_recv()
@ 2024-07-04  7:47 Roman Smirnov
  2024-07-04  9:52 ` [BlueZ,v2] " bluez.test.bot
  0 siblings, 1 reply; 3+ messages in thread
From: Roman Smirnov @ 2024-07-04  7:47 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Roman Smirnov

It is necessary to add return value check as in sock_send().

Found with the SVACE static analysis tool.
---
 V1 -> V2: the name of the patch has been shortened 
 client/player.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/client/player.c b/client/player.c
index 0d031e4b0..1340a7584 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);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread
* [PATCH BlueZ v2] client/player: add error code handling to transport_recv()
@ 2024-07-04 10:49 Roman Smirnov
  2024-07-04 12:41 ` [BlueZ,v2] " bluez.test.bot
  0 siblings, 1 reply; 3+ messages in thread
From: Roman Smirnov @ 2024-07-04 10:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Roman Smirnov

It is necessary to add return value check as in sock_send().

Found with the SVACE static analysis tool.
---
 V1 -> V2: the name of the patch has been shortened
 client/player.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/client/player.c b/client/player.c
index 0d031e4b0..1340a7584 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);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-07-04 12:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-04  7:47 [PATCH BlueZ v2] client/player: add error code handling to transport_recv() Roman Smirnov
2024-07-04  9:52 ` [BlueZ,v2] " bluez.test.bot
  -- strict thread matches above, loose matches on Subject: below --
2024-07-04 10:49 [PATCH BlueZ v2] " Roman Smirnov
2024-07-04 12:41 ` [BlueZ,v2] " bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.