diff options
author | Joseph Hwang <josephsih@chromium.org> | 2022-02-16 16:15:18 +0800 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2022-02-23 08:57:33 -0800 |
commit | d89af9acb7283f8f446c976a0f3f425424768d1e (patch) | |
tree | 78a24b967bcdda8952f8d9fc885e6f9b97cf218a /monitor/analyze.c | |
parent | b086260ac6d4ac765bdc443bb50bd304b0d076c9 (diff) | |
download | bluez-d89af9acb7283f8f446c976a0f3f425424768d1e.tar.gz |
monitor: fix division by zero about conn->tx_pkt_med
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>
Diffstat (limited to 'monitor/analyze.c')
-rw-r--r-- | monitor/analyze.c | 3 |
1 files changed, 2 insertions, 1 deletions
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 */ |