diff mbox series

[BlueZ,v1] client/player: add return value check of io_get_fd() to transport_recv()

Message ID 20240702115138.70500-1-r.smirnov@omp.ru
State Superseded
Headers show
Series [BlueZ,v1] client/player: add return value check of io_get_fd() to transport_recv() | expand

Commit Message

Roman Smirnov July 2, 2024, 11:51 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(-)

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 14:51:38 +0300 you wrote:
> 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(-)

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

You are awesome, thank you!
diff mbox series

Patch

diff --git a/client/player.c b/client/player.c
index 7a7598c39..b1ebcaa37 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);