diff mbox series

[BlueZ,v1] monitor: fix division by zero about conn->tx_pkt_med

Message ID 20220216081518.2956782-1-josephsih@chromium.org (mailing list archive)
State Accepted
Commit d89af9acb7283f8f446c976a0f3f425424768d1e
Headers show
Series [BlueZ,v1] monitor: fix division by zero about conn->tx_pkt_med | 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/setupell success Setup ELL PASS
tedd_an/buildprep success Build Prep PASS
tedd_an/build success Build Configuration PASS
tedd_an/makecheck success Make Check PASS
tedd_an/makecheckvalgrind success Make Check PASS
tedd_an/makedistcheck success Make Distcheck PASS
tedd_an/build_extell success Build External ELL PASS
tedd_an/build_extell_make success Build Make with External ELL PASS

Commit Message

Joseph Hwang Feb. 16, 2022, 8:15 a.m. UTC
In a connection without outgoing traffic, conn->tx_num will remain 0.
In this case, conn->tx_pkt_med should be simply 0 without calculating
"conn->tx_bytes / conn->tx_num".

This was likely to happen, for example, when "btmon -w btsnoop.log"
was launched in the middle of a LE mouse connection, and a number of
incoming ACL Data RX were received as the mouse movements.  When
running "btmon -a btsnoop.log", it would encounter this error.

Reviewed-by: Alain Michaud <alainm@chromium.org>
Reviewed-by: Yun-Hao Chung <howardchung@chromium.org>
Reviewed-by: Shuo-Peng Liao <deanliao@chromium.org>
Signed-off-by: Joseph Hwang <josephsih@chromium.org>
---

 monitor/analyze.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

bluez.test.bot@gmail.com Feb. 16, 2022, 9:43 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=614851

---Test result---

Test Summary:
CheckPatch                    PASS      1.49 seconds
GitLint                       PASS      1.01 seconds
Prep - Setup ELL              PASS      51.66 seconds
Build - Prep                  PASS      0.93 seconds
Build - Configure             PASS      10.55 seconds
Build - Make                  PASS      1818.86 seconds
Make Check                    PASS      12.41 seconds
Make Check w/Valgrind         PASS      534.70 seconds
Make Distcheck                PASS      283.60 seconds
Build w/ext ELL - Configure   PASS      10.79 seconds
Build w/ext ELL - Make        PASS      1795.15 seconds
Incremental Build with patchesPASS      0.00 seconds



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/monitor/analyze.c b/monitor/analyze.c
index 0c74e8f2e..ac23e13bb 100644
--- a/monitor/analyze.c
+++ b/monitor/analyze.c
@@ -161,7 +161,8 @@  static void conn_destroy(void *data)
 		break;
 	}
 
-	conn->tx_pkt_med = conn->tx_bytes / conn->tx_num;
+	if (conn->tx_num > 0)
+		conn->tx_pkt_med = conn->tx_bytes / conn->tx_num;
 
 	printf("  Found %s connection with handle %u\n", str, conn->handle);
 	/* TODO: Store address type */